scp removing the file after successful copy?

Andrew Pollock andrew-ssh at andrew.net.au
Wed Oct 30 14:53:53 EST 2002


On Wed, Oct 30, 2002 at 01:16:07PM +1100, Damien Miller wrote:
> Andrew Pollock wrote:
> >G'day,
> >
> >Sorry for the intrusion, just wondering if there are any plans to add a -u
> >type option to scp like the commercial SSH's scp has, which removes
> >the file after a successful copy? (particularly when copying a remote file 
> >to local)
> [snip]
> >I did a quick search of this lists' archives, and I can see some comments
> >relating to this sort of functionality in the past, including some
> >patches, but it never seems to have made it into the mainstream release.
> 
> scp is officially in maintenance mode, i.e. no new features. It is based 
> on a 20+ year old protocol and codebase which we don't want to extend 
> further.

Bugger :-(
 
> wrt your request, it may be possible to script this using scp exit 
> status (though I saw some emails that this may be unreliable).
> 
> 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.

Basically, everything I've seen to work around this limitation has been 
decidely kludgey.

Might have to look at rsync instead.

Andrew



More information about the openssh-unix-dev mailing list