login about faq

Is it possible to copy a remote file on the SFTP server to file w/ a different name/path also on the remote server? In other words, I do not want to upload or download a file, but I want to have the SFTP server make a copy of the file. Is this possible?

asked Apr 19 '13 at 10:00

chilkat's gravatar image

chilkat ♦♦

This is not possible to do using the SFTP protocol. If you examine the protocol specification (http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02) you'll see that the possible packet types (i.e. commands) that can be sent from the client to the server are as follows:

        #define SSH_FXP_INIT                1
        #define SSH_FXP_VERSION             2
        #define SSH_FXP_OPEN                3
        #define SSH_FXP_CLOSE               4
        #define SSH_FXP_READ                5
        #define SSH_FXP_WRITE               6
        #define SSH_FXP_LSTAT               7
        #define SSH_FXP_FSTAT               8
        #define SSH_FXP_SETSTAT             9
        #define SSH_FXP_FSETSTAT           10
        #define SSH_FXP_OPENDIR            11
        #define SSH_FXP_READDIR            12
        #define SSH_FXP_REMOVE             13
        #define SSH_FXP_MKDIR              14
        #define SSH_FXP_RMDIR              15
        #define SSH_FXP_REALPATH           16
        #define SSH_FXP_STAT               17
        #define SSH_FXP_RENAME             18
        #define SSH_FXP_READLINK           19
        #define SSH_FXP_SYMLINK            20
        #define SSH_FXP_STATUS            101
        #define SSH_FXP_HANDLE            102
        #define SSH_FXP_DATA              103
        #define SSH_FXP_NAME              104
        #define SSH_FXP_ATTRS             105
        #define SSH_FXP_EXTENDED          200
        #define SSH_FXP_EXTENDED_REPLY    201

There is no feature to "copy" a file. It is possible to rename a file.

To make a copy of a file, one could instead use the Chilkat SSH API to remotely login and issue a remote "cp" command (or "copy" if the server is Windows).


answered Apr 19 '13 at 10:04

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Apr 19 '13 at 10:00

Seen: 1,108 times

Last updated: Apr 19 '13 at 10:04

powered by OSQA