scp: Problem when source and destination are identical

Jason Stone jason at shalott.net
Fri May 18 07:59:29 EST 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> > If the source and destination file are identical, the receiving scp
> > truncates the file.  On the sending end, read() returns 0, and garbage
> > is sent instead of actual data, and the receiving end puts it into the
> > file, which at least confuses the users.
> 
> This comes up every now and then.  Except for the simple case where both
> files are local, how's scp really to know?
> 
> ...Now, to throw some fuel on the fire: is there any room (i.e. would the
> way scp is done even allow) for the equivalent of the -i option for cp? 
> ("Overwrite file 'foo'? y/N") I'm betting not, and the right answer for
> things like that is "use rsync over ssh instead of scp."

Another solution to your problem is the patch posted by Wayne Davison a
couple days ago to scp files into a unique temp name on the remote side
and then atomically move the new file over the old file.

http://marc.theaimsgroup.com/?l=openssh-unix-dev&m=98987013832587&w=2

I used to do the same thing with shell script wrappers - having scp do it
is simpler.


 -Jason

 ---------------------------
 If the Revolution comes to grief, it will be because you and those you
 lead have become alarmed at your own brutality.         --John Gardner



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (FreeBSD)
Comment: See https://private.idealab.com/public/jason/jason.gpg

iD8DBQE7BEnEswXMWWtptckRAqnoAKCqNqMoOdsECwN6R2zrAuHOwD8YSwCeMoSi
LjB17ZuaWGNI+8LZY1REjaE=
=JwAB
-----END PGP SIGNATURE-----




More information about the openssh-unix-dev mailing list