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

spawn ftp $HOSTNAME 
expect "Name (sj105ut01:laureen):"
send "laureen\r"
expect "Password:"
send "password\r"
expect "ftp>"
send "cd path\r"
expect "ftp>"
send "put local_file.t.Z remote_file.t.Z"
expect "ftp>"
send "bye\n"
#interact

When I try to unzip the file on the server using (tar xzf) I get the following error:

tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar: Error is not recoverable: exiting

What might be the causes of this? and is there any way to fix it?

When it starts executing the put command, I get this on the screen:

150 Opening BINARY mode data connection for remote_file.t.Z

and then I get the shell back. I suppose I should be seeing something to indicate that the transfer is complete but I'm not. sth like:

226 Transfer complete 147742720 bytes sent in 27.3 secs (5420.58 Kbytes/sec)

The size of the file: Local: 142M, while remote : 56M!

thanks

1
If you are PUTting compressed binary files, you should set binary mode first!!! jscape.com/blog/…Mark Setchell
The default is binary, and I have already tried to set it using binary command and it is still corrupted.loreen99
Ok, I suggest you compare the file lengths on the local machine and the remote to see if they are grossly different, slightly different, or identical. That may give a hint as to whether your transfer has gone grossly wrong, or just a few line endings are wrong, or if the files are the same size but the data is somehow corrupted.Mark Setchell
Local: 142 M, while remote : 56M! so I guess that's hugely different.loreen99
Try setting the expect timeout higher - it looks like it times out after 10s at 5MB/s tcl.tk/man/expect5.31/expect.1.htmlMark Setchell

1 Answers

0
votes

If your file takes longer than 10 seconds to upload, you are hitting expect's default timeout: while expecting to see the "ftp>" prompt after sending the "put" command, after (default) 10 seconds, expect gives up times out and continues on with the next command (send bye).

Try this:

set timeout -1
send "put local_file.t.Z remote_file.t.Z"

Also, after you "send bye" you should wait for the connection to end:

send "bye\r"
expect eof