cURL / Mailing Lists / curl-users / Single Mail

curl-users

RE: Renaming files via SFTP connection

From: balsamik1 <balsamik1_at_gazeta.pl>
Date: Fri, 14 Jan 2011 11:00:02 -0500

>> curl -u user:pass sftp://host.domain.com/~/mydir -Q 'rename file1 file2'
> I would've guessed this should work. I don't know why it doesn't. Does -v
> output offer any clues?

Here is the output from the two versions of the command:

Working example:
----------------

(1) curl -u user:pass sftp://host.domain.com -Q 'rename /home/user/mydir/file1
/home/user/mydir/file2'

* About to connect() to host.domain.com port 22 (#0)
* Trying 999.999.1.1... connected
* Connected to host.domain.com (999.999.1.1) port 22 (#0)
* Failed to read known hosts from /home/localuser/.ssh/known_hosts
* SFTP 0x8209e98 state change from SSH_STOP to SSH_S_STARTUP
* SFTP 0x8209e98 state change from SSH_S_STARTUP to SSH_HOSTKEY
* SSH host check: 0, key: AAAA.....=
* SFTP 0x8209e98 state change from SSH_HOSTKEY to SSH_AUTHLIST
* SSH authentication methods available: publickey,gssapi-with-mic,password
* SFTP 0x8209e98 state change from SSH_AUTHLIST to SSH_AUTH_PKEY_INIT
* Using ssh public key file /home/localuser/.ssh/id_dsa.pub
* Using ssh private key file /home/localuser/.ssh/id_dsa
* SFTP 0x8209e98 state change from SSH_AUTH_PKEY_INIT to SSH_AUTH_PKEY
* SSH public key authentication failed: Unable to open public key file
* SFTP 0x8209e98 state change from SSH_AUTH_PKEY to SSH_AUTH_PASS_INIT
* SFTP 0x8209e98 state change from SSH_AUTH_PASS_INIT to SSH_AUTH_PASS
* Initialized password authentication
* SFTP 0x8209e98 state change from SSH_AUTH_PASS to SSH_AUTH_DONE
* Authentication complete
* SFTP 0x8209e98 state change from SSH_AUTH_DONE to SSH_SFTP_INIT
* SFTP 0x8209e98 state change from SSH_SFTP_INIT to SSH_SFTP_REALPATH
* SSH CONNECT phase done
* SFTP 0x8209e98 state change from SSH_SFTP_REALPATH to SSH_STOP
* DO phase starts
* SFTP 0x8209e98 state change from SSH_STOP to SSH_SFTP_QUOTE_INIT
* Sending quote commands
* SFTP 0x8209e98 state change from SSH_SFTP_QUOTE_INIT to SSH_SFTP_QUOTE
* SFTP 0x8209e98 state change from SSH_SFTP_QUOTE to SSH_SFTP_QUOTE_RENAME
* SFTP 0x8209e98 state change from SSH_SFTP_QUOTE_RENAME to SSH_SFTP_NEXT_QUOTE
* SFTP 0x8209e98 state change from SSH_SFTP_NEXT_QUOTE to SSH_SFTP_TRANS_INIT
* SFTP 0x8209e98 state change from SSH_SFTP_TRANS_INIT to SSH_SFTP_READDIR_INIT
* SFTP 0x8209e98 state change from SSH_SFTP_READDIR_INIT to SSH_SFTP_READDIR
* SFTP 0x8209e98 state change from SSH_SFTP_READDIR to SSH_SFTP_READDIR_BOTTOM
drwxr-xr-x 65 root root 12288 Jan 12 09:31 etc
.
.
(shortened to remove root directory content list)
.
.
* SFTP 0x8209e98 state change from SSH_SFTP_READDIR_BOTTOM to SSH_SFTP_READDIR
* SFTP 0x8209e98 state change from SSH_SFTP_READDIR to SSH_SFTP_READDIR_BOTTOM
drwxr-xr-x 19 root root 4096 Jun 19 2009 usr
* SFTP 0x8209e98 state change from SSH_SFTP_READDIR_BOTTOM to SSH_SFTP_READDIR
* SFTP 0x8209e98 state change from SSH_SFTP_READDIR to SSH_SFTP_READDIR_DONE
* SFTP 0x8209e98 state change from SSH_SFTP_READDIR_DONE to SSH_STOP
* DO phase is complete
* SFTP 0x8209e98 state change from SSH_STOP to SSH_SFTP_CLOSE
* SFTP DONE done
* SFTP 0x8209e98 state change from SSH_SFTP_CLOSE to SSH_STOP
* Connection #0 to host host.domain.com left intact
* SSH DISCONNECT starts now
* SFTP 0x8209e98 state change from SSH_STOP to SSH_SFTP_SHUTDOWN
* SFTP 0x8209e98 state change from SSH_SFTP_SHUTDOWN to SSH_SESSION_DISCONNECT
* SFTP 0x8209e98 state change from SSH_SESSION_DISCONNECT to SSH_SESSION_FREE
* SFTP 0x8209e98 state change from SSH_SESSION_FREE to SSH_STOP
* SSH DISCONNECT is done
* Closing connection #0

Non-working example:
--------------------

(1) curl -u user:pass sftp://host.domain.com/~/mydir -Q 'rename file1 file2'

* About to connect() to host.domain.com port 22 (#0)
* Trying 999.999.1.1... connected
* Connected to host.domain.com (999.999.1.1) port 22 (#0)
* Failed to read known hosts from /home/localuser/.ssh/known_hosts
* SFTP 0x8209ef0 state change from SSH_STOP to SSH_S_STARTUP
* SFTP 0x8209ef0 state change from SSH_S_STARTUP to SSH_HOSTKEY
* SSH host check: 0, key: AAA....=
* SFTP 0x8209ef0 state change from SSH_HOSTKEY to SSH_AUTHLIST
* SSH authentication methods available: publickey,gssapi-with-mic,password
* SFTP 0x8209ef0 state change from SSH_AUTHLIST to SSH_AUTH_PKEY_INIT
* Using ssh public key file /home/localuser/.ssh/id_dsa.pub
* Using ssh private key file /home/localuser/.ssh/id_dsa
* SFTP 0x8209ef0 state change from SSH_AUTH_PKEY_INIT to SSH_AUTH_PKEY
* SSH public key authentication failed: Unable to open public key file
* SFTP 0x8209ef0 state change from SSH_AUTH_PKEY to SSH_AUTH_PASS_INIT
* SFTP 0x8209ef0 state change from SSH_AUTH_PASS_INIT to SSH_AUTH_PASS
* Initialized password authentication
* SFTP 0x8209ef0 state change from SSH_AUTH_PASS to SSH_AUTH_DONE
* Authentication complete
* SFTP 0x8209ef0 state change from SSH_AUTH_DONE to SSH_SFTP_INIT
* SFTP 0x8209ef0 state change from SSH_SFTP_INIT to SSH_SFTP_REALPATH
* SSH CONNECT phase done
* SFTP 0x8209ef0 state change from SSH_SFTP_REALPATH to SSH_STOP
* DO phase starts
* SFTP 0x8209ef0 state change from SSH_STOP to SSH_SFTP_QUOTE_INIT
* Sending quote commands
* SFTP 0x8209ef0 state change from SSH_SFTP_QUOTE_INIT to SSH_SFTP_QUOTE
* SFTP 0x8209ef0 state change from SSH_SFTP_QUOTE to SSH_SFTP_QUOTE_RENAME
* rename command failed: No such file or directory
* SFTP 0x8209ef0 state change from SSH_SFTP_QUOTE_RENAME to SSH_SFTP_CLOSE
* SFTP DONE done
* SFTP 0x8209ef0 state change from SSH_SFTP_CLOSE to SSH_STOP
* DO phase is complete
* Connection #0 to host host.domain.com left intact
curl: (21) rename command failed: No such file or directory
* SSH DISCONNECT starts now
* SFTP 0x8209ef0 state change from SSH_STOP to SSH_SFTP_SHUTDOWN
* SFTP 0x8209ef0 state change from SSH_SFTP_SHUTDOWN to SSH_SESSION_DISCONNECT
* SFTP 0x8209ef0 state change from SSH_SESSION_DISCONNECT to SSH_SESSION_FREE
* SFTP 0x8209ef0 state change from SSH_SESSION_FREE to SSH_STOP
* SSH DISCONNECT is done
* Closing connection #0

Thanks,

Tomasz

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-01-14