ActiveState Community

Spawning Plink fails

Posted by tonyb1008 on 2009-03-05 09:51

I am writing a script that uses Expect and I try to spawn a connection to a remote host using plink. Plink is an SSH connection tool that allows for command line interaction. I am running this on a Windows PC running Win XP. The version of Active State Tcl version is 8.5.6.0. The error I get this:

expect: spawn id exp2 not open
while executing

Should I be using spawn? Is there another way to launch plink and still interact with it?

Here is basic part of the script:

#!/bin/sh
# The next line is executed by /bin/sh, but not tcl \
#exec wish "$0" ${1+"$@"}
exec tclsh85

package require Expect

wm withdraw .
console show

set currDir [pwd]
set outputFile "$currDir/log_Out.txt"

set remoteIP "10.10.102.41"
set userID admin
set userPW admin

set timeout 20
after 50 {set newMsg 1}
vwait newMsg

set prompt {CPE41:}

log_file $outputFile

spawn plink $remoteIP
set plink_id $spawn_id
after 1000
expect {
-nocase -re "(login as:)" {exp_send "$userID\r"}
}
.
.
.

Thanks for the help.

Tony

tonyb1008 | Thu, 2009-03-05 10:28

Hello all,

I read another post about Expect and Windows DEP (Data Execution Prevention) feature. I hadn't checked that before because I was able to run the script using the Tcl 8.4 version. I went and turned off DEP for the plink.exe application and the newer version of Tcl and the scrip is working now.

By the way DEP control can be found by right-clicking on the My Computer icon and selecting Properties. Then click on the Advanced tab and then click on the Performance Settings. The windo that opens up has the DEP tab.

Tony