sftp script failing when one of the sftp statement fails in Linux
<p>I am having an OpenSSH <code>sftp</code> script which transfer the files from a SFTP server (Solaris) to application server (Linux). Here the scenario is the transfer happens from different location and same files are transferred backup to SFTP server different location. But if any of the transfers fail due to file is not available, it is not continuing the remaining <code>sftp</code> commands. Instead it just comes out of the code. Below is the script.</p>

<pre class="lang-none prettyprint-override"><code>export SSHPASS=*******
/usr/local/bin/sshpass -e sftp -oPort=22 -oBatchMode=no -b - rkwlahtt@10.204.140.14 &lt;&lt; !

cd /home/rkwlahtt/Inbound
mget *.*
rm *.*
cd /home/rkwlahtt/Inbound/Adhoc
mget *.*
rm *.*
cd /home/rkwlahtt/Archive/Inbound
mput *.TXT
mput *.txt
cd /home/rkwlahtt/Archive/Adhoc
mput *.xlsx
bye
!
</code></pre>

<p>Here in the above script when I am trying to <code>mget</code> from <code>/home/rkwlahtt/Inbound</code> folder and if file doesn't exist, it just comes out of the <code>sftp</code> code instead of going to next command that is <code>cd /home/rkwlahtt/Inbound/Adhoc</code> and <code>mget</code>. This is the same situation while <code>mput</code> too. </p>

<p>This is the first time we are transferring from different location in the same code. And this is creating issue in our transferring.</p>

<p>Please let me know what can be done to resolve this issue.</p>