lftp is not working.how to replace lftp with expect utility using same .cfg file.

We have lftp command inside shell file. which is intern calling .cfg file for transferring the file from one server to other.

Below command to not working.

lftp -e "set net:max-retries 1; set net:reconnect-interval-base 1; put -E -O /destinationdir/inbox/ /sourcedir/test.txt; bye" -u userid,password sftp://destinationserver.COM/

output:

sourcedir/test.txt; bye" -u userid,password sftp://destinationserver.COM/                                                                                             <
`sourcedir/test.txt' at 0 (0%) [Connecting...]
 
Log from scp � timeout error:
debug2: fd 3 setting TCP_NODELAY
debug2: callback done
debug2: channel 0: open confirm rwindow 131072 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
Sending file modes: C0640 0 test.txt
Received disconnect from 64.26.250.52: 11: Connection timeout.
lost connection
....

So we installed the expect utility and tested the connection . Able to connect the Destination server and folder. Can you please let me know how to use expect utility to call .cfg file ?

As of now we have .cfg file called by lftp (which is not working).

this is the line in our code to call

lftp -e "set net:max-retries 1; set net:reconnect-interval-base 1; put -E -O ${DST_DIR} ${FILE_NAME}; bye" -u ${SFTP_USER},${SFTP_PASS} sftp://${HOST}/ #>>${FTPLOG}

and config file has below details.

PROCESS_NAME|PROTOCOL|user|ASCII/BIN|dest_hostname|src_folder|dst_folder|archive_folder|error_folder|filename_with_path
ABCD|SFTP|userid:password||destinationServer.COM|sourcedir|destinationdir|archivedir||0

This is first time , I am working on Shell Script. can you please help.

Regards,
Babu

---------- Post updated at 10:30 PM ---------- Previous update was at 09:56 PM ----------

to add more details on this.

Same lftp is working one of the Linux Server(A). Transferring files to Destination Server(B).( A to B transfer )

Same lftp is not working from Linux Server(C).(C to B transfer failing)
. Is there any configuration needs to done at Destination Server (B) in order to get files from Server (C) ?

Does the lftp invocation work from the command line? Or do you get the same errors as in the shell script? Can you use ssh and lftp interactively from the failing client to the server?

Have you tried this slight alteration?

lftp -e "set net:max-retries 1; set net:reconnect-interval-base 1; cd ${DST_DIR}; put  ${FILE_NAME}; bye" -u ${SFTP_USER},${SFTP_PASS} sftp://${HOST}/ 

lftp is designed to be scriptable; you shouldn't need to use it with expect.

Andrew

Hi Andrew,

Thanks a lot for responding.

lftp -e "set net:max-retries 1; set net:reconnect-interval-base 1; cd ${DST_DIR}; put  ${FILE_NAME}; bye" -u ${SFTP_USER},${SFTP_PASS} sftp://${HOST}/

I have tried executing only the above command.

Output stuck like below:

cd `sftp://userid@HOST/' [Connecting...]

Do you know is it issue with Host server ?

Regards,

Probably.

1 Like

What happens when you run lftp (and also sftp ) interactively? What are the differences between the three machines?

Andrew

1 Like