We help IT Professionals succeed at work.
Get Started

Script to check remote server for file

pride-it asked
Last Modified: 2012-05-12
I am using rsync to transfer files and sync with remote server, but need to expand on script to check and see if the file exists in another directory on the same remote server, and if it does , do not run rsync command.  Would like to program in bash or ksh shell.

If the specific file in the source directory on the target server in
the  /n01/uat2/prod11iappl/ilink/11.5.0/processed directory, then I don't need to copy that file - it has already been processed.

If it doesn't exist in that directory, then I need to check if the file exists on the target server in the  /n01/uat2/prod11iappl/ilink/11.5.0/incoming directory.

If it doesn't exist  in /n01/uat2/prod11iappl/ilink/11.5.0/incoming , then you need to copy that file to that directory.

Here is the rsync command I am using:
rsync -avvvvz -e "ssh -i /home/rsync/.ssh/mesa-rsync-key" /n01/applprod/PROD11i/appl/ilink/11.5.0/processed/TO*.AXML rsync@extapuata: /agile:oaan01/uat2/prod11iappl/ilink/11.5.0/incoming/
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE