0

I have to cleanup an archive directory on a remote host only if there are files to be archived; the source files are on the same host. I should run something similar to:

cd $source_dir
if [ -f *.tar.gz ]
then
  rm -fr $arch_dir/*
  mv *.tar.gz $arch_dir
fi

The problem is that I can use only scp, rsync or sftp. How to achieve this?

1

given those requirements, why not use something like python/perl on the client side for an interactive sftp session, then you can easily check for the file existence in the archive directory and move the files, etc.

http://www.pythonforbeginners.com/modules-in-python/python-secure-ftp-module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.