Hi,
I have changed the script as
#
echo "cd /home/data/" > getFilelist
echo "ls -l "ABC*" >> getFilelist
echo "quit" >> getFilelist
sftp -b getFilelist user@hostname >filelist <<EOF
#
which is now giving the output as
sftp> cd /home/data
sftp> ls -l ABC*
-rw-r--r-- 0 13106 7745 0 Mar 29 07:34 ABC29073411
-rw-r--r-- 0 13106 7745 0 Mar 29 07:34 ABC29073412
-rw-r--r-- 0 13106 7745 0 Mar 29 07:34 ABC29073413
-rw-r--r-- 0 13106 7745 0 Mar 29 07:34 ABC29073415
sftp> exit
To get ris of first 2 and last line, I tried using all the below script but not a single record is getting copied to new file.
I tried executing the below scripts on unix prompt and they are working file but these script are not working inside the shell script.
#
1) /usr/bin/sed 's/sftp//g' filelist > filelist1
2) sed '1,2d' filelist > filelist1 and sed '$d' filelist >> filelist1
3) sed '/sftp/d' filelist > filelist1
4) grep -v 'sftp' filelist > filelist1
#
The filelist1 file does not contain any record.
please advise.
---------- Post updated at 05:09 PM ---------- Previous update was at 03:39 PM ----------
I think I found the issue.
The first sftp command is closing the complete script due to which the rest of the script is not executing.
I have created another script just to connect the host server and calling the new script from first script.
Hope this will work.
---------- Post updated at 05:36 PM ---------- Previous update was at 05:09 PM ----------
Done.
Finally I am able to create the script which will fetch all the latest files from remote server.
Thanks you very much all for your support and inputs.