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
 
20.9.2014 - We have just updated our course layouts and descriptions and added our 2015 schedule.

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., 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