[wplug] script / expect
Alexandros Papadopoulos
apapadop at cmu.edu
Wed Feb 12 00:39:26 EST 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dear all
I'm trying to add some interactivity to a shell (bash) script. It
currently accepts an IP as a command line parameter, and does some
automated tests on the host.
What I want to add, is the ability to have small chats with the host.
For instance, if port 23 is found to be open, I want the script to
telnet to the host, wait for the prompt, and then hang up, recording
any data received in the process.
This expect script chats successfully, when invoked from the command
line:
#!/usr/bin/expect -f
set force_conservative 0
set IP $env(IP)
spawn $env(SHELL)
send "telnet $IP\r"
expect "login: "
send "^]"
expect "telnet> "
send "q\r"
expect "Connection closed.\r"
send "^D"
expect eof
Now, how is it possible to call this from within the shell script,
record (with script $IP.txt) everything that happens, then stop
recording once the expect chat is over, and pass control back to the
shell script? (try saying that in one breath)
Any pointers/suggestions would be appreciated!
- -A
- --
http://andrew.cmu.edu/~apapadop/pub_key.asc
3DAD 8435 DB52 F17B 640F D78C 8260 0CC1 0B75 8265
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+Sd4OgmAMwQt1gmURAqHpAJwLILOPcoH8RCr5zAA5IOiPRfyv5wCfdOhn
Y0zzjSB9TbH/C9K+WvGZZjQ=
=qJPf
-----END PGP SIGNATURE-----
More information about the wplug
mailing list