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))
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 192.168.2.4
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 192.168.19.7 , I do not know how to proceed as if I  do  "spawn ftp 192.168.19.7" 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 192.168.19.7" and not spawn "ftp 192.168.19.7"

thanks and regards



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