Training, Open Source computer languages

This is page http://www.wellho.net/forum/The-Tcl- ... guage/Control-Multiple-Spawn-telnetthrough-single-script.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
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))
Control Multiple Spawn telnetthrough single script

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
It's probably hanging up someehere in the send and expect sequence - probably a tiny error in your choreography.  And as you've not got any puts statements anywhere in your code, there's no output at all so you're not being given any clues!

As a first step, I would remove the
log_user 0
so that all the protocol exchanges will be echoed on the screen. That way' you'll see where it comes to a halt.


Posted by mansoorx (mansoorx), 16 March 2006
I just remove the log_user 0 and run it again but again it take almost 4 minut to execute but, port 23 is not configured at all , and display in that format ,
in linux this script after excution,

[mansoor@tech mansoor]$ ./mspawn
spawn telnet 192.168.0.9
spawn telnet 192.168.0.47
[mansoor@tech mansoor]$


Posted by admin (Graham Ellis), 16 March 2006
Then your problem lies at the very beginning with the spawn ... it's not getting any login offer back so you're having a timeout at each and every stage.   Try running the telnet from a shell and see what's happening.


Posted by mansoorx (mansoorx), 1 April 2006
Hello Graham,

Sorry for delay, due to some reasons, any when i telnet from shell it work very well, but whenever i run this script spawn takes time, and dont implement any configuration on the switches.

Posted by admin (Graham Ellis), 1 April 2006
.... and having now run it from telnet, look and see exactly what the difference are and that should lead you in the right direction ...



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.

© 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