[ale] expect scripting question

Gene Matthews gene at mmc-inc.com
Thu Apr 11 16:46:12 EDT 2002


I'm trying to write an expect script to test a remote console server.

I have the following script:


#!/usr/bin/expect -f

spawn telnet $argv
expect "login:"
send "voicetek\r"
expect "Password: "
send "itsasecret\r"
expect ":ccs"
send "show\r"
expect "rcm:ccs"
send "exit\r"


This script works fine standalone (e.g. ./rcmcheck servername). 
However, what I would like to do is call it from perl script and be able
to test it's success.  

My perl script first tries to ping the box, and if the box is reachable
I want to call this expect script and be able to determine if the telnet
was successful.  I want to be able to determine if the telnet connection
is 1) refused, 2) times out, or 3) successful.

My expect skills are very new (i.e. weak).  Does expect have an 'exit'
statement similar to perl (and shells) and some conditional structures? 
Can anyone give me some advice/pointers or point me to any good online
resources for learning expect?

Thanks.

Gene Matthews
Matthews Midrange Consulting, Inc.
(678) 923-8327
(877) 882-6291 (toll free)
http://mmc-inc.com


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list