scp removing the file after successful copy?

Ben Lindstrom mouring at etoh.eviladmin.org
Wed Oct 30 15:16:47 EST 2002


On Wed, 30 Oct 2002, Andrew Pollock wrote:

> On Wed, Oct 30, 2002 at 01:16:07PM +1100, Damien Miller wrote:
[..]
> > sftp's exit status should be reliable for this sort of thing (if not
> > file a bug), so "sftp blah remote: && rm -f blah" should work.
>
> That works for local to remote file transfers, however for remote to local
> transfers and unlinking the remote file, it's somewhat more difficult.
> Particularly in a restricted environment where you can't run arbitrary
> commands via SSH on the remote host. Or where /bin/rm isn't available but
> unlink() is.
>

sftp has batch mode.  Where if any command being ran fails to complete
correctly the script is aborted.  So you can do like

get file
rm file

in a file and do: sftp -b script site

If the get fails to succeed the script should automaticly bail out so the
rm is never ran.

> Basically, everything I've seen to work around this limitation has been
> decidely kludgey.
>
> Might have to look at rsync instead.
>

In general I think rsync is better.

- Ben




More information about the openssh-unix-dev mailing list