In remote server, there are always a pair of files like:-
in folder /Pair1
in folder /Pair2
This is just an example of files. There will be a lot of them generated in one day.
File name in a pair is always same except for timestamps. From other server, I need to SFTP to the remote server and check one pair by one pair.
Logic: The script should check if .out file is there, then grab/download the .txt file (from the pair). Once the .txt file is transferred/downloaded successfully, script will go back to remote server and delete the .out file.
This is my test script:-
lftp sftp://$UserID:$PASSWORD@10.x.x.x -e "ls /home/adm/testfiles|grep .out; bye" >> $LOG if [ $? -eq 0 ] then echo "Files exist, getting *.txt" >> $LOG lftp sftp://$UserID:$PASSWORD@10.x.x.x -e "mget /home/adm/testfiles/*.txt -O /home/adm/test/ ; bye" >> $LOG else echo ".out files do not exist" >> $LOG fi
The problem is that, it will list out all files with extension .out instead of checking pair by pair. I do not know how to classify a pair. I am not good in scripting, so, I have to ask for some help.