Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Languages and Scripting
Showing results for 
Search instead for 
Did you mean: 

Expect "spawn" command hangs

Occasional Visitor

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 ""
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
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)



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?

John Seel
Occasional Advisor

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.



John Seel
Occasional Advisor

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!
John Seel
Occasional Advisor

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 to and a couple other girations...) but all is working now.



Narendra Uttekar
Regular Advisor

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




John Seel
Occasional Advisor

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/ -->

Had to copy to /usr/lib/hpux32 

Occasional Visitor

Re: Expect "spawn" command hangs

Do you have the 8.5.8 version depot package?
John Seel
Occasional Advisor

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.



Carlo Corthouts
Frequent Advisor

Re: Expect "spawn" command hangs

I know it is an old post, but installing the tcl/tk 8.5.19 seems to resolve the problem as well,

On some systems it still might cause a coredump, but this is due to a bug which is resolved by renaming /usr/local/lib/history.tcl