Ftp over telnet over expect
Posted by sou5437 (sou5437), 18 August 2005I want to telnet to a gateway server and frm tht server ftp to a destination host and then get the file back to my original host through the gateway.
Using expect I can telnet to the gateway by spawning telnet with the ip but how to spawn ftp to the destination host staying within this earlier spawned telnet process connected to gateway.
Thanks in advance.
Posted by Custard (Custard), 18 August 2005Hi,
Not sure I really know the answer to this. Needs a bit of experimentation & thought.
One thing that came to mind was when you have telnetted to the gateway, send an ftp command to connect to the remote host, and instead of doing a plain 'get' do a 'get thing.txt -' which (from memory) streams the requested file to STDOUT. You ought to be able to grab that stream via expect.
You'll have to be careful with binaries though... YMMV as they say!
FWIW my experiment on fetching a jpeg gave this:
Let us know how you get on..
Posted by sou5437 (sou5437), 19 August 2005hi
ya you are almost right.I left the idea of spawning a ftp from another telnet instead i send ftp staying within the telnet.And finally got the file at the gateway.
But now facing another problem.
*) While getting the file i need to verify the checksum of the file.So i am using unix cmd SUM to do that.But problem is over a ftp connection you cant run SUM.Also over telnet , if i try to set a variable with the result like
set res [exec SUM $file] then this SUM actually runs on local host instead of remote host.
But when i send the SUM $file over a telnet it shows the result at the terminal.
Can you show me a way to capture the outcome of a send command in a string.I guess tht would be helpful
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho