Training, Open Source computer languages

PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site 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))
expect script aborting in the middle.

Posted by manicisco (manicisco), 14 July 2007
Folks,
           I am running the below expect script on my windows XP laptop with Active tcl 8.4.14.0.It telnets to the router and logs in using the username and password.But it exits immediately without doing anything more.

Script
****

package require Expect
set timeout 60
set username ww
set password ww
set target 172.21.55.140
spawn telnet $target
expect "name"
exp_send "$username\r"
expect "word"  
exp_send "$password\r"
expect  "DCN"
exp_send "show ip route\r"


Script Execution
**************


User Access Verification

Username: ww
Password:

DCN-CAT-10>
C:\Tcl>

Basically I am expecting the script to run the "Show ip route" command after authentication.

Posted by admin (Graham Ellis), 15 July 2007
I think you're "send"ing before the incoming string has completed.  Rather than expect "word", try doing expect "word: " - otherwise you'll start sending the password before the telnet daemon is ready for it, loose the first few characters, resulting in an incorrect password being received and a host that won't let you log in.

P.S. You should do the same thing for the user name, though that may not be critical as you have type ahead buffering - but type ahead buffering rarely works with passwords.



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.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
+44 PH: (0) 1225 708 225 • FAX: (0) 1225 707 126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho