expect the unexpected!
I do hate it when people say that, because ....
But since I am not a total pedant and only have 9/10 for getting side tracked I
am posting to ask if anyone knows why my expect script does not work. It apears
to log on ok to my remote linux box, but fails to execute anything. I am
planning to launch grip, xterm's and the like as I dont have enough monitors,
keyboards, space for them or arms as long as my network cabels.
Anyway the scripts is like this
---------------CUT here--------------------------------
#!/usr/bin/expect --
#
# In this program, we telnet to a host, execute two commands,
# and leave.
# prevent an untimely end. If you have a command that takes a
# time, adjust this
set timeout 5000
# We start a telnet session.............................
spawn telnet 192.168.0.97
# A telnet session begins with a login prompt, so we 'expect'
# one here, and send the username in response.
# The \r represents a carriage return. Everytime you would press
# <Enter>
# interactively, send a \r.
expect "login: "
send "oms101\r"
# We then send the password, note thats not my password
expect "assword: "
send "mylittlelinuxbox\r"
send "xterm &\r"
# We know in advance what our command prompt is, and we
# 'expect' it accordingly. If we get it, we send the
# 'mkdir test' and press enter (\r)
expect " >"
send "mkdir test\r"
exit
---------------CUT here--------------------------------
maybe it is time to learn python! anyway some background here is a screen
scrape from the execution of the script
---------------CUT here--------------------------------
>fred_grip
spawn telnet 192.168.0.97
Trying 192.168.0.97...
Connected to 192.168.0.97.
Escape character is '^]'.
Welcome to SuSE Linux 7.0 (i386) - Kernel 2.2.16 (2).
ford login: oms101
Password:
Last login: Wed Mar 28 10:00:24 from charly.local
Have a lot of fun...
oms101@ford:~ > >
---------------CUT here--------------------------------
and here is what happens when I telnet in and ls the root directory
unfortunately no sign of my new test directory, whats going on?
---------------CUT here--------------------------------
oms101@ford:~ > ls
mp3 nsmail wav
oms101@ford:~ >
---------------CUT here--------------------------------
Chears
Owen
Date: 30-Jul-01 Time: 19:47:52