Re: Expect scripting



Here is the code I am trying to run. What I am trying to accomplish,
rather badly, is that if the command is entered with the arguements

li.exp l L i

,then the script would telnet to and login then transfer control back
to the user; however, if the following were to be entered

li.exp l L

,then the script would login and then send commands and capture them
to a file.

Right now if I put 'i' as the third arguement then it works properly,
but if I do not put the third arg then two things happen; first, the
program hangs until ^D is sent and then it telnets/logs-in, but the
script file is capturing the shell cmd line and the commands are never
sent to the telnet session. Originally, I thought it was just how I
had the file names that the commands were not being sent to the telnet
session, but now I think I have a different problem.

##########################################################

set mso [lindex $argv 0]
set equip [lindex $argv 1]
set login $env(LOGNAME)
set password [getpasswd "$equip"]
set mode [lindex $argv 2]
set mydate [exec date +%m%d%y]
set home $env(HOME)

if {$mode == "i"} {set mode "1"
} else { set mode "0" }

switch -- $equip \
L {
set outputfile $msoid\_$equipid-autodump.
$mydate.txt
set activeFile [open $home/ke010596/$equipid\cmdfile.txt"]
if { $mode == 0 } {
set counter "0"
exec script $outputfile
spawn telnet $msoTelnet$fourthOctet
expect "COMPL"
send "utl::login,user $login\r"
expect "PASSWORD"
send "$password\r"
expect "!"
while {[gets $activeFile line] != -1 } {
incr counter
send "$line\r"
expect "COMPL"
}
} elseif { $mode == 1 } {
spawn telnet $msoTelnet$fourthOctet
expect "COMPL"
send "utl::login,user $login\r"
expect "PASSWORD"
send "$password\r"
expect "!"
interact

etc.......
#####################################################

.



Relevant Pages

  • Re: Matching long strings doesnt work
    ... longer commands, ie go from 1024 to 16K characters. ... Below here is one version of the script I'm testing. ... # I usually telnet to the same computer, but I can change if I want to. ... It's going to take a long time to send out 16K characters but give it a shot. ...
    (comp.lang.tcl)
  • Re: Expect scripting
    ... ,then the script would telnet to and login then transfer control back ... script file is capturing the shell cmd line and the commands are never ... sent to the telnet session. ... expect "COMPL" ...
    (comp.lang.tcl)
  • Re: send command
    ... It's a shell script that comes with Expect. ... the command line and starts recording everything you type: telnet, ... -- everything you do is recorded as a series of expect/send commands. ... Connection closed.\r ...
    (comp.lang.tcl)
  • UPDATE: Keeping Telnet Session Open
    ... even tell script what commands to run in a non-interactive, ... see the telnet running in the psoutput. ... the other end is accepting the connection. ...
    (SunManagers)
  • =?ISO-8859-1?Q?New_System_Command_Script_Facility?=
    ... I'm currently finished writing a new replacement command script processor ... (at least that RACF thinks so, and better support for non-RACF sites). ... The IF-type commands now have ELSE processing ... non-scroll highlighted console message and BEEP until a specific JOB or TASK ...
    (bit.listserv.ibm-main)