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.

using multiple spwans for diff commands

Posted by vishalshukla_83 (vishalshukla_83), 22 November 2005
i am trying to create multiple sessions using multiple spwaning at a single time, and then using them to simultaneously giving commands to the routers. it is going fine , but routers are not getting "\r" command..i just want to give a simple return at some place. here is the code. any one can help?
foreach x $ulist {
expect "*#"
send -i $x " reload \r "
expect -i $x "*:" {send -i $x " no \r "}
expect -i $x "*m]" {send -i $x " y \n \r  \r"}
#exit 1
}

just jumping out of confirm command

Thanks in Advance,
Vis

Posted by admin (Graham Ellis), 23 November 2005
I think I need to know a bit more to understand the question.  You've got a list of spawn_id-s in $ulist have you?

You then keep waiting on the LATEST process started for a # and when you get it, you send a reload command to each of the spawned processes in turn, waiting on each of them for a further response ...  do I have that right, or should you have had a -i $x in the first expect perhaps?  That would seem more logical, but not knowing your application ...

Posted by vishalshukla_83 (vishalshukla_83), 23 November 2005
Hi Graham,

Thanks for quick help!! your understanding is right. i have found out the working verison of that code aslo. in fact what waas happening that after sending the "reload command" it was expecting for some thing " *]:" and then it had to send "no" after that a comfirmation asking dialouge comes like [confirm], then it had to send "y\r". Actually what i did was just removed the expecting of this "[confirm]" as it comes directly after asking "*]:" and it is not a valid promt. so the code finally was:

foreach x $ulist {
expect "*#"
send -i $x " reload \r "
expect -i $x "*:" {send -i $x " no \r\r "}
}

Please note that  i have added one more "\r" so as to send "return" to that [confirm] ( here i was expecting it as "*m]" ) statement .

Thanks,
Vis


Posted by mansoorx (mansoorx), 15 March 2006
Hello,
        I am trying to develope a programme, through which i can access two different Cisco Switch at the same time and open its port no 23, but when i execute this script it does not display any message and i press   "Crtl + c " to come back in Linux command promt.

#!/usr/bin/expect -f
set switch {192.168.0.3 192.168.0.4}
set running 0
log_user 0

foreach x $switch {
spawn telnet $x
expect -i $x "Username:"
send -i $x "name\r"
expect -i $x "Password:"
send -i $x "password\r"
expect -i ">"
send -i $x  "enable\r"
expect -i $x "Password:"
send -i $x "password\r"
expect -i $x "#"
send -i $x "conf t"
expect -i $x "#"
send -i $x "int fas 0/23\r"
expect -i $x "#"
send -i $x "no sh\r"
expect -i $x "#"
send -i $x "do wr"
expect -i $x "#"
send -i $x "do exit\r"
}

Thank You Advanced.

Posted by admin (Graham Ellis), 15 March 2006
Hello ... how does the question relate to the previous discussion on this thread?   Or would this be better as a separate thread?

It's helpful if you can start new questions in new threads as it can get very time consuming to try to sort out all the various parts if they're combine .... and a new question is likely to be better seen too!



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