Re: Expect "spawn" command hangs (1116 Views)
Reply
Occasional Visitor
seel6395
Posts: 1
Registered: ‎11-18-2013
Message 1 of 9 (1,360 Views)

Expect "spawn" command hangs

HPUX version 11iV3 (B.11.31)
Expect version 5.45
All dependencies for Expect loaded properly.

I have just loaded expect and eventually want to use it connect to an sFTP server that I do not manage. The vendor who manages the sFTP server uses only password authentication, not key exchange.

I've tested a simple script (see below) and will expand on it when I get it to work.
Manually connecting to the sFTP server works fine.

When running the Expect script, it hangs at the spawn command until I issue a control C, which of course also terminates the program. I have tested this with several spawned commands including telnet, and ksh. It doesn't seem to matter what it tries to spawn, it still hangs.

I have googled this issue and found only two similar issues, one was related to a bug in Cygwin, the other was resolved by spawning a ksh shell and then using "send" to send a telnet command. But the Cygwin bug does not apply to HPUX and spawning a shell results in the same problem.


I suspect an HPUX bug, but can't confirm that and don't know what to do if it is.
Any help would be greatly appreciated.

Here is the basic script (user name, password, and server redacted):
#!/usr/local/bin/expect -d
spawn "user@server.com"
expect "password:"
send "password\n"
expect "sftp>"
send "mget *.* \r"
expect "sftp>"
send "quit \r

And here is the debug:
expect version 5.45
argv[0] = /usr/local/bin/expect argv[1] = -d argv[2] = ./sftptest
set argc 0
set argv0 "./sftptest"
set argv ""
executing commands from command file ./sftptest
spawn sftp user@server.com
parent: waiting for sync byte

                   <----- Hangs here forever until I issue Control C

parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {9247}
sighandler: handling signal(2)
async event handler: Tcl_Eval(exit 130)

--------------------------------------------

Visitor
Nev4321
Posts: 1
Registered: ‎06-28-2011
Message 2 of 9 (1,314 Views)

Re: Expect "spawn" command hangs

We too have suffered the same issue (HP-UX 11.31, expect 5.45, tcltk 8.5.15) - "expect spawn sftp..." hangs! 

 

Investigation of the probem lead us to beleive the issue is with tcl (expect calls tcl to accomplish various tasks) because if you try to run an external command in the tcl shell (tclsh) then the comman does not execute, it hangs as per the expect spawn symptoms.

 

eg tclsh % ls   <--- hangs

 

Also we have a server running  HP-UX 11.31, expect 5.45, tcltk 8.5.8 and this combination does not suffer from the problem - expect spawn and tclsh external commands all run as expected.

 

So on the problem server we removed tcltk 8.5.15 and installed 8.5.8.

 

Our expect scripts now execute as expected.

 

So what version of tcltk are you running? If tcltk 8.5.15, can you install an older version?

Occasional Advisor
John Seel
Posts: 5
Registered: ‎05-16-2005
Message 3 of 9 (1,310 Views)

Re: Expect "spawn" command hangs

We are in fact running tcl 8.5.15.

 

Thanks! I will try to load an earlier version. I will let you know.

 

 

Occasional Advisor
John Seel
Posts: 5
Registered: ‎05-16-2005
Message 4 of 9 (1,308 Views)

Re: Expect "spawn" command hangs

do you know where I can get tcl 8.5.8?
The HP porting site only seems to have 8.5.15.
I prefer the depot package instead of trying to build it.
Thanks again!
Occasional Advisor
John Seel
Posts: 5
Registered: ‎05-16-2005
Message 5 of 9 (1,299 Views)

Re: Expect "spawn" command hangs

Thanks again!

I was unable to locat a depot file for tcl 8.5.8, but I was able to download, configure, and install 8.5.8 from the source code. I had to rename some files (tclsh8.5 was renamed tclsh, and was libtcl8.5.so to libtcl.so and a couple other girations...) but all is working now.

 

Thanks!

Regular Advisor
Narendra Uttekar
Posts: 236
Registered: ‎12-30-2007
Message 6 of 9 (1,116 Views)

Re: Expect "spawn" command hangs

Hi John,

I am also facing same problem for expect...

(HP-UX 11.31, expect 5.45, tcltk 8.5.15 and all dependencies for tcltk installed ) - "expect spawn sftp..." hangs! 

 

Please can you let me know in detail how you got the tcltk 8.5.8 source code working on HP-UX 11.31. As when i tried to

build TK 8.5.8 getting error as below, But i have successfully build the TCL 8.5.8.

100 errors detected in the compilation of "/tmp/tcltk-8.5.8-src/unix/../generic/tk3d.c".

Compilation terminated.

*** Error exit code 4

 

Thanks,

Narendra

Occasional Advisor
John Seel
Posts: 5
Registered: ‎05-16-2005
Message 7 of 9 (1,105 Views)

Re: Expect "spawn" command hangs

Hello Narendra,

I did not have any issues compiling tcl8.5.8.

Make sure that you have all the dependencies loaded properly.

I just downloaded the source and ran "configure", "make", and "make  install".

 

After the compile, I did have to rename some files for expect to work properly.

 

/usr/local/bin/tclsh8.5 -->tclsh

/usr/local/lib/libtcl8.5.so --> libtcl.so

Had to copy libtcl.so to /usr/lib/hpux32 

Occasional Visitor
foxni
Posts: 1
Registered: ‎07-21-2014
Message 8 of 9 (540 Views)

Re: Expect "spawn" command hangs

Do you have the 8.5.8 version depot package?
Occasional Advisor
John Seel
Posts: 5
Registered: ‎05-16-2005
Message 9 of 9 (532 Views)

Re: Expect "spawn" command hangs

No. I had to download and compile it.

You should be able to google "download tcl 8.5.8" and find it. It will have to be built and compiled, though.

 

 

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.