Issues with terminal freezing after scp in expect script.

Damo, David David.Damo@CIBC.com
Wed Jan 20 23:34:00 GMT 2010


Okay the issue was with expect. The weird thing is I tried break before and it froze so I assumed it was not the issue. After restarting the terminal break worked:

            "Are you sure you want to continue connecting (yes/no)?" {exp_send "yes\r"}

            "*assword:" { send "$unixpass\r"; }

Needs to be:

            "Are you sure you want to continue connecting (yes/no)?" {exp_send "yes\r"}

            "*assword:" { send "$unixpass\r"; break }

If hung on password so I had to restart my terminal. Weird.

David

-----Original Message-----
From: Damo, David 
Sent: Wednesday, January 20, 2010 3:04 PM
To: 'cygwin@cygwin.com'
Subject: Issues with terminal freezing after scp in expect script.

Hi,

 

I have interesting problem. I have bash script that calls an expect script that works fine and does an scp. However after the scp the terminal freezes. It is stuck on the bash prompt, however the prompt is not the original prompt. After I do ctrl C it continues to process. I tried to do a ctrl c/break/exit in the expect script, but it does not work. Any ideas what could be causing the problem? Scripts are below:

 

Bash script:

 

#!/usr/bin/bash

 

echo `date`  " - Starting shell script."

 

touch /apps/sjsws/sunws-automation/https-autodemo.cibcwm.com/docs/runshell

 

echo `date` " - Copy files."

 

expect /apps/sjsws/sunws-automation/https-autodemo.cibcwm.com/docs/SMWeblogic/SMWeblogiccp.exp $1 $2 $5 $6

 

file=`basename $1`

 

echo `date` " - Run build on: " $file

# expect /apps/sjsws/sunws-automation/https-autodemo.cibcwm.com/docs/SMWeblogic/SMWeblogicrun.exp $1 $2 $5 $6 $3 $4

 

echo `date`  " - Finished."

 

 

Expect script:

 

#!/usr/local/bin/expect -f

#

set filename [lindex $argv 0]

set hostname [lindex $argv 1]

set uu [lindex $argv 2]

set unixpass [lindex $argv 3]

 

set force_conservative 0  ;# set to 1 to force conservative mode even if

                                      ;# script wasn't run conservatively originally

if {$force_conservative} {

            set send_slow {1 .1}

            proc send {ignore arg} {

                        sleep .1

                        exp_send -s -- $arg

            }

}

 

 

set timeout -1

spawn $env(SHELL)

match_max 100000

send -- "scp $filename $uu@$hostname:/tmp/\r"

while {1} {

        expect {

            "Are you sure you want to continue connecting (yes/no)?" {exp_send "yes\r"}

            "*assword:" { send "$unixpass\r"; }

        }

    }

exp_send -- " 


--------------------------------------------------------------------------------
"

send -- "exit\r"

sleep 10

# send -- "scp /apps/sjsws/sunws-acs/https-acsdemo.cibcwm.com/docs/archives/smasa-12.zip $uu@$hostname:/tmp/\r"

while {1} {

        expect {

            "Are you sure you want to continue connecting (yes/no)?" {exp_send "yes\r"}

            "*assword:" { send "$unixpass\r"; }

        }

    }

sleep 30

send -- "exit\r"

expect eof

 

Thanks,


David J

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list