tags:

views:

163

answers:

1
package require Expect

#### Log File Name #####
set logFile "mtte_result.log"
set NextLine "\n"
set RTSPrompt "RTS_Mon-> "
exp_spawn plink.exe -telnet -P 10009 10.245.97.42

set spid $spawn_id
#exp_send $NextLine
flush stdout

##### Log the session to the File   #########
    exp_log_file -noappend $logFile

exp_sleep 5
exp_send $NextLine
expect $RTSPrompt
exp_send "hello world\r"

expect $RTSPrompt
exp_sleep 5
exp_close -i $spid
########################################################
########################################################

Here logfile has output as:

RTS_Mon-> 

*RTS_Mon-> 

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

so it seems as if input is not forced to the process. Is there something wrong to above script ???

A: 

I don't known if it was a copy&paste error, but I don't think your code will work, should be something like:

package require Expect
# Log File Name
set logFile "mtte_result.log" 
set NextLine "\n" 
set RTSPrompt "RTS_Mon-> " 
exp_spawn plink.exe -telnet -P 10009 10.245.97.42
set spid $spawn_id
exp_send $NextLine
flush stdout
# Log the session to the File
exp_log_file -noappend $logFile
exp_sleep 5 
exp_send $NextLine 
expect $RTSPrompt 
exp_send "hello world\r"
expect $RTSPrompt 
exp_sleep 5 
exp_close -i $spid

Also make sure that the "exp_spawn" returns properly

Carlos Tasada