I am using expect
I dont know tcl but trying to use a control statement to send requests from an input file - dont know what I am doing to be honest as I dont know tcl and dont use expect too much...
Any help?
See below
Basically I am opening a telnet session to a server which works fine and I can send one command. I want to put several commands in to a file- just an example below.. and the error when I try to run this is below also
ie - file is called test.txt and contains
df -k
ps -ef
ls -ltr /etc/
==============================
# Open a telnet session to a remote server, and wait for a username prompt.
spawn telnet $remote_server
expect "USERCODE:"
# Send the username, and then wait for a password prompt.
send "xxxxxxx\r"
expect "PASSWORD:"
# Send the password, and then wait for a shell prompt.
send "xxxxxxx\r"
expect "<"
# Send the prebuilt command, and then wait for another shell prompt.
send "$my_command\r"
for i in `cat testfm.txt`; send "echo $i\r" ; done
expect "<"
# Capture the results of the command into a variable. This can be displayed, or written to disk.
set results $expect_out(buffer)
# Exit the telnet session, and wait for a special end-of-file character.
send "exit\r"
expect eof
==============================
invalid command name "i"
while executing
"i"
("for" initial command)
invoked from within
"for i in `cat test.txt`"
(file "./.test_script" line 24)