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.
spawn from a spawned process

Posted by awalia (awalia), 7 August 2005
I have a scenario, when I log in to a router by telnet, and then I want to initiate a ftp session from the router to get a file.
I want to use expect to do it, I use the following

spawn telnet
expect "login:" {send "xyz\r"}
expect "Password" {send "default\r"}
expect "router>" {send "cd \tmp\r"}
expect "router\tmp>"

at this point, I want to initiate a ftp session to a server say , I do not know how to proceed as if I  do  "spawn ftp" it will open a ftp session from my linux workstation, where as intent is to open it from the router, get the file and quit from the ftp session and then continue to configure the router.

any help will be highly appreciated.

Posted by admin (Graham Ellis), 7 August 2005
If you want to spawn another process on the same machine that you're running the current script on, then save the spawn_id and you can then spawn the second process.  

If you want to spawn a process on a remote machine you've s telnet'ed  (or ssh'd) to, you should ensure that expect is available on that machine too and that a script to run the ongoing process is there.

From your description, I believe you have the second scenario.  It's quite unusual to have to "double bank" expect like this, and it can be hard to debug and support.  I suggest that you might tdo better running commands directly in the remote shell and controlling them from the first telnet session; that way, all your program remians on the one machine.

Posted by awalia (awalia), 8 August 2005
Thanks for the reply.  Yes, your guess was correct, I was trying for the 2nd.

I tried your suggestion and it works, I  used
send "ftp" and not spawn "ftp"

thanks and regards

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