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

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: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho