Re: copy a bunch of rile, then delete from source



On 10/04/2008, Ugo Bellavance <ugob@xxxxxxxx> wrote:

Hi,

Here is what I want to do:

- Copy a number of files (using a wildcard, like logapplication*.tar.gz)
from one server to another
- Once done, I want to delete the files from the source server.

The first step is easy to do... ssh keys, cronjob, and scp. However, can
I be sure that the file has been copied successfully? I thought of
comparing md5sums source/destination before deleting the source.

Could rsync be of help?

Regards,

Ugo


for i in logapplication*.tar.gz
do
scp -p $i user@remote-host:
if ((! $?))
then
rm $i
else
echo "copy of $I failed"
fi
done

$? is the return status of the previous command. If the scp is successful,
it will return 0.
0, somewhat contradictory, means "false" to an if-statement. Hence, "if ((!
$?))" = "if not false" = "if copy successful", remove the source file.

Kind regards,

Herta

--
"Life on Earth may be expensive,
but it comes with a free ride around the Sun."
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list



Relevant Pages

  • Re: SCP help
    ... > I have developed a CGI that will take information from a CGI based ... > SCP a specific file to a remote server. ... > If I do the above command from the command line all works perfectly. ...
    (perl.beginners)
  • Re: SFTP and SCP
    ... > Both scp and sftp use insecure protocols which derive their security from ... In what way do you see sftp as having "improved ... with wildcard expansion. ... matching rules chosen by the server. ...
    (comp.security.ssh)
  • master script to keep specified number of child processes running until entire task finished
    ... multi-cpu servers, in a timely manner without swamping the server. ... I've created a kludge of a ksh that'll let me do the compress or scp ... It takes a template command with a placeholder ... echo $THE_COMMAND ...
    (comp.unix.shell)
  • Re: smbfs 2 GB file size limit
    ... Was your issue with reading from or writing to a SMB share? ... What is the server software and OS version? ... What error message are you getting from your FreeBSD client? ... Did you really mean to say scp or cp? ...
    (freebsd-questions)
  • Re: smbfs 2 GB file size limit
    ... >> Was your issue with reading from or writing to a SMB share? ... >> What is the server software and OS version? ... > Did you really mean to say scp or cp? ... > specifying it's dialect capabilities in the smb negotiation. ...
    (freebsd-questions)