Using expect command, spawn will not start sftp process

Hi all,

I have a script that runs sftp with expect so I can login and send a file in a cronjob. I've installed this on a couple other servers and it has been fine. However, this time on this machine, it seems to be giving me an issue. It won't move past the spawn sftp command and return a linux PID.

First the basics:

The server is running Red Hat Linux Release 7.3 (Valhalla)
uname -a shows Linux 2.4.20-28.7smp #1 SMP i686

I installed Expect-5.45 and Tcl-8.5.12

This is the script:

#!/usr/bin/expect -f
set location "."

spawn sftp username@secureftp.ftpserver.com
expect "password:"
send "userpw\r";
set timeout -1
send "put localfile.txt remotefile.txt\r";
send "quit\r"
expect eof

Pretty simple and straight forward, right?

When I run it with the -d flag to see what is happening, I get this output:

expect version 5.45
argv[0] = /usr/bin/expect  argv[1] = -d  argv[2] = ./scriptname.ftp
set argc 0
set argv0 "./scriptname.ftp"
set argv ""
executing commands from command file ./scriptname.ftp
spawn sftp username@secureftp.ftpserver.com
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child

And that is where it stops. It does not give me "spawn: returns [PID number]" and does not move on.

Any ideas? What am I missing here?

I appreciate any help you can give me, I've been searching and searching for an answer to no avail.

Thank you,

Laura

Does it fail only under cron?

I never even got as far as putting it on a cron job. This was running the script manually logged in as su (root).

if I run the "sftp username@secureftp.ftpserver.com" from the prompt I can connect with no issues, which is why I suspect the issue is with spawn.

Thanks,

Laura

Sometimes an strace reveals what is going on, especially if you compare it to a good running host strace.