Feature requests for scp and ssh

Simon Kissane skissane at gmail.com
Mon Jan 17 12:18:17 EST 2005


Hi,

Thanks Darren for your prompt reply.

On Mon, 17 Jan 2005 11:43:08 +1100, Darren Tucker <dtucker at zip.com.au> wrote:
> Simon Kissane wrote:
> > Would it be possible to add an option to the scp command, so that if a
> > destination file already exists, rather than overwriting it, scp just
> > skips the destination file, prints a message to stderr and returns an
> > error (non-zero) exit? That would help me immensely.
> 
> That would require another option to be passed to the remote scp process
> to enable that behaviour, which would be a potential interop problem.
> This means it's not likely to ever happen (see
> http://www.openssh.com/faq.html#2.10).
[snip]

Another proposal I might make then: enhance sftp's command line
interface so it supports some of scp's syntax. So, at present it
supports:
sftp user at host:file file => similar to scp user at host:file file [get remote file]

So, it could be extended to support the syntax:
1) sftp file user at host:file [put remote file, like scp file user at host:file]
2) sftp user1 at host1:file1 user2 at host2:file2 [transfer between remote hosts]
(The second syntax might require extensions to the SFTP protocol, and
in any case is not so important as the first.)

Then, a command line argument could be given with syntax (1) not to
overwrite the remote file. This wouldn't require any protocol changes
(it would simply do behind the scenes what you suggested to do
manually).

So that solves my problem, is simpler for the user than the current
solution you propose (one command, v.s. two commands plus shell
control structures), and is possible with no changes to the sftp
protocol (for syntax 1 at least).

Although, using the two commands and the control structure you proposed, ie.:
$ echo "ls /tmp/foo" | sftp -b - localhost || \
       echo "put foo /tmp/foo" | sftp -b - localhost
does yield a race condition (another user could have created file
after ls but before put). It would be better if there was an extension
to the SFTP protocol to provide an option on put to not open the file
if it exists, so the server would open the file O_EXCL.

Cheers
Simon Kissane




More information about the openssh-unix-dev mailing list