Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Ftp over telnet over expect

Posted by sou5437 (sou5437), 18 August 2005
I 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 2005
Hi,

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:

Code:
ftp> get rlPerl.jpg -
200 PORT command successful.
150 Opening BINARY mode data connection for rlPerl.jpg (811 bytes).
ˇˇ‡JFIFˇC
..... MORE BINARY GARBAGE ....                    yk@>&#8216;&#168;&#8250;&#732;s3s&#8230;_,87az&#8212;DQ?<\&#8230;]&#8706;$Z&#8222;&#8747;&#8221;H&#8216;6&#711;226 Transfer complete.
remote: rlPerl.jpg
811 bytes received in 0.025 seconds (31.14 Kbytes/s)
ftp>


Let us know how you get on..

B

Posted by sou5437 (sou5437), 19 August 2005
hi
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




This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho