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 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
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

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:

ftp> get rlPerl.jpg -
200 PORT command successful.
150 Opening BINARY mode data connection for rlPerl.jpg (811 bytes).
..... 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)

Let us know how you get on..


Posted by sou5437 (sou5437), 19 August 2005
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 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., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho