Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP within Net::Telnet

Status
Not open for further replies.

skar

MIS
Mar 21, 2001
37
GB
Hi all,

I'm doing some work that envolves me telneting to a unix box. Then ftping onto another unix box and downloading files.
I've written the script to do all the stuff for the telnet but I'm having problems getting FTP to work. I've tried to use the telnet->cmd("ftp hostname"); but thats as far as I can go. Almost as if any commands to the ftp client on the remote unix box are being ignored.
I've tried to use Net::FTP but cant work out how to use it from within the Net::Telnet session.
Can anyone point me in the right direction??

Thanks
Skar
 
The FTP module cannot be used in this fashion as far as I am aware.

In order to carry out a similar task to what you are wanting to do I use Net::Telnet to access the intermdiate machine and run unix 'remsh' commands to do what I need to do on the third machine. The results of the 'remsh' commands are written to the intermediate machine where they can be brought to the first machine using either Telnet or Ftp modules.

Here is a line from my perl script:

@data = $host->cmd(String => 'remsh machine3 "find /usr/users/user1 -exec ls -lAdL {} \;" > ~/config_man/from_machine3.txt');

Using the Telnet module, the above line contacts machine 2 and on it runs the system command "remsh machine 3 etc", obtaining a file listing from machine 3. The output is written to ~/config_man/from_machine3.txt on machine 2, where the same script can copy the from_machine3.txt file to machine 1, either using the telnet or ftp modules.

I hope that makes sense: it does start to get rather complicated :)


 
I did think of the remsh command but the 2nd unix box is behind a couple of firewalls. So I have to use FTP to leapfrog from one firewall through the 2nd firewall and then onto the 2nd unix box. <hmmm.... think that sounds ok>

What I might end up doing is writing a script using Net::FTP and just running it on the 1st unix box.

Oh well. Things to think about... :)

Thanks for the swift reply.

Skar
 
You should use SSH!!!!!!!!

you can ssh into the &quot;telnet&quot; box (shudder, insecure telnet, ick!) using public key exchange (no password required) and have that session run one or more commands as a local session on the SSH'd (formerly telnetted box).

Telnet is evil and sloppy. Er, well, SSH allows you to securely script your way to success, even if you generate the script on the fly with perl.

You might find this setup doc interesting... its about using CVS instead of FTP, but the principals still apply.

Good luck.


&quot;Surfinbox Shares&quot; - A fundraising program that builds revenue from dialup Internet users.
 
I agree. Telnet is not secure. But at this moment in time telnet is all I have. The unix box in question is a test system.
We do use SSH within our live environment. :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top