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
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho