I need to make a Unix script, where i need ftp and sftp functionality.
Let me describe in details:
I need to import few files from remote server, now these remote server either support ftp or sftp not both. So i need a script where my script will try to do ftp first and if it gets succeeded then come out of script and if not then try to do sftp on that server.
Hope i briefed properly, if not please let me know what other information requires. Please help me on this.
Also i tried these two codes individually, do i need to take care of something while using ftp and sftp together, or it will just work fine if ill add IF condition
It clearly shows that ftp is not happening on this host so ideally it shuold try doing sftp but its not coming to sftp syntax rather its coming out of script...
You set the RC=$? 'too late' = its not working after EOF parts...
Because, the Return code comes from the successfull ended EOF, not the last command that was executed inside that EOF section.
Thus it'll report the wrong result..
ftp: connect: Connection timed out
Not connected.
Successful ftp...0 2014-01-31-09.15.33
Now in my code i want to go to sftp because ftp not working but its not going, probable reason would be the rc value is coming 0 as "not connected is string not numerical value " so not able to negate the first if condition...
can anyone suggest work around please
TIA
---------- Post updated at 04:25 AM ---------- Previous update was at 04:21 AM ----------
Hi,
SO can i put
rc=$?
if [[ $rc -eq 0 ]]; then
echo "Successful ftp...$rc" `date "+%Y-%m-%d-%H.%M.%S"` >> $log