Sftp hanging at exit

Hi All

I was trying to execute below sftp command.

 
 
echo "cd /${CUST_ID}/inbound/${SAFET_ID}" > $BATCHFILE
echo "put ${SOURCE_FILE} ${FILE_NAME}" >> $BATCHFILE
echo "exit" >> $BATCHFILE
cmd="sftp -o port=2022 -b $BATCHFILE user@$SERVER"
$cmd >> $LOGFILE 2>&1
if [ $ret -ne 0 ] 2>>$LOGFILE
then
echo "Failure" >> $LOGFILE
else
echo "Success">> $LOGFILE
fi

[/CODE]
But in log i can see the output till exit. sftp is hanging at exit, if-else condition is not getting executed.

Request you to suggest a solution

Can you run this manually by the same user account non-batch mode first, and if so, can you run this with the commands in a batch? That might give a clue as to why this might be getting stuck.

I hope that this helps

Robin
Liverpool/Blackburn
UK

Hi thanks for the reply. But i cant execute from the same user. The script is getting called from GUI

---------- Post updated at 09:27 PM ---------- Previous update was at 09:25 PM ----------

And one more important thing is this issue is happening randomly. Not frequently.

This may be more indicative of network problems than sftp problems, I'm thinking. How large are these files you're uploading?