Re: Expect scripting
- From: Knilges <knilges@xxxxxxxxxxx>
- Date: 19 May 2007 16:38:38 -0700
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.......
#####################################################
.
- Follow-Ups:
- Re: Expect scripting
- From: Cameron Laird
- Re: Expect scripting
- References:
- Expect scripting
- From: Knilges
- Re: Expect scripting
- From: Bryan Oakley
- Re: Expect scripting
- From: Knilges
- Re: Expect scripting
- From: Bryan Oakley
- Expect scripting
- Prev by Date: tooltips/balloon help on menubar pulldowns
- Next by Date: Re: TCL code to read a following file
- Previous by thread: Re: Expect scripting
- Next by thread: Re: Expect scripting
- Index(es):
Relevant Pages
|