unexpected Expect issue for a newbie
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

unexpected Expect issue for a newbie

From: <ctiberius@gmail.com>
Date: Wed Jun 29 2005 - 22:45:20 CEST

This is on Aix 5.2.

I execute this:

#!./usr/local/bin/expect -d
set timeout 10
spawn scp ldapstatus.html buildusr@10.13.106.57:.
expect "*password*"
set send_slow {1 0.05}
send -s "pwd\r"
send_user "********"
expect eof

and I get this:

[/home/buildusr]# ./test5.sh
expect version 5.43.0
argv[0] = ./usr/local/bin/expect argv[1] = -d argv[2] = ./test5.sh
set argc 0
set argv0 "./test5.sh"
set argv ""
executing commands from command file ./test5.sh
spawn scp ldapstatus.html buildusr@10.13.106.57:.
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {15970}

expect: does "" (spawn_id exp4) match glob pattern "*password*"? no
buildusr@10.13.106.57's password:
expect: does "buildusr@10.13.106.57's password: " (spawn_id exp4) match
glob pattern "*password*"? yes
expect: set expect_out(0,string) "buildusr@10.13.106.57's password: "
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "buildusr@10.13.106.57's password: "
send: sending "1Purple1\r" to { exp4 }
********
ldapstatus.html 100% 93 0.0KB/s
00:00
expect: read eof
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "\r\n\rldapstatus.html
              0% 0 0.0KB/s --:-- ETA\rldapstatus.html
                     100% 93 0.0KB/s 00:00 \r\n"

Hm. Ok. My file gets transferred and then I have what appears to be a
hang or a crash or a really long wait for something to happen. I never
get my OS Korn shell back. I have to manually kill my putty session.

If I execute this:

#!./usr/local/bin/expect -d
set timeout 10
spawn scp ldapstatus.html buildusr@10.13.106.57:.
expect "*password*"
set send_slow {1 0.05}
send -s "pwd\r"
send_user "********"
wait

I get this:

[/home/buildusr]# ./test4.sh
expect version 5.43.0
argv[0] = ./usr/local/bin/expect argv[1] = -d argv[2] = ./test4.sh
set argc 0
set argv0 "./test4.sh"
set argv ""
executing commands from command file ./test4.sh
spawn scp ldapstatus.html buildusr@10.13.106.57:.
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {16010}

expect: does "" (spawn_id exp4) match glob pattern "*password*"? no
buildusr@10.13.106.57's password:
expect: does "buildusr@10.13.106.57's password: " (spawn_id exp4) match
glob pattern "*password*"? yes
expect: set expect_out(0,string) "buildusr@10.13.106.57's password: "
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "buildusr@10.13.106.57's password: "
send: sending "pwd\r" to { exp4 }
********

My file doesn't get transferred. Expect just sits there waiting for
something that doesn't seem like it will ever happen. I can hit ctrl-C
and of course it stops and returns to the OS shell prompt.

I try close:

#!./usr/local/bin/expect -d
set timeout 10
spawn scp ldapstatus.html buildusr@10.13.106.57:.
expect "*password*"
set send_slow {1 0.05}
send -s "pwd\r"
send_user "********"
expect eof
close

and I get:

[/home/buildusr]# ./test6.sh
expect version 5.43.0
argv[0] = ./usr/local/bin/expect argv[1] = -d argv[2] = ./test6.sh
set argc 0
set argv0 "./test6.sh"
set argv ""
executing commands from command file ./test6.sh
spawn scp ldapstatus.html buildusr@10.13.106.57:.
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {14640}

expect: does "" (spawn_id exp4) match glob pattern "*password*"? no
buildusr@10.13.106.57's password:
expect: does "buildusr@10.13.106.57's password: " (spawn_id exp4) match
glob pattern "*password*"? yes
expect: set expect_out(0,string) "buildusr@10.13.106.57's password: "
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "buildusr@10.13.106.57's password: "
send: sending "pwd\r" to { exp4 }
********
ldapstatus.html 100% 93 0.0KB/s
00:00
expect: read eof
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "\r\n\rldapstatus.html

                    0% 0 0.0KB/s --:-- ETA\rldapstatus.html

                                 100% 93 0.0KB/s 00:00 \r\n"
spawn_id: spawn id exp4 not open
    while executing
"close"
    (file "./test6.sh" line 10)

and the same interminable 'hang' waiting for something. Rather, I
suppose it is expecting something. Since, you know, it's called Expect.

I can understand that I can't close a spawn that isn't open. That makes
sense. But why can't I get back to my shell?

Help for a newbie please.
Received on Thu Sep 29 14:23:52 2005