Hi Experts,
I am writing one shell script. Below is the requirement
- need to login to the SFTP server, go to the particular folder
- take the file count in that folder and assign it to variable
- came out of the SFTP server and check the condition, if the file count is less than the required count exit the script other wise further processing
- then we need to move the files from SFTP to another server.
- Need to check the file count in another server if all the files are not copied print the error msg and exit the script.
please help me with the sudo code. I am trying the below code it is getting error.
sftp ${SftpPort} ${userid}@${host name} "cd ${SFTP_SRC_DIR} <<sftp_test_EOF
count_src=`ls -ltr *.csv} | wc -l`
sftp_test_EOF"
echo $count_src
if [ $count_src -lt 3 ]
then
echo "All CSV files not present in sftp"
exit 1
fi