Hi,

I need to copy (not move) a file from one location on an SFTP server to another location on the same SFTP server. I found this answer for the FTP component but the SFTP component does not have the CopyToAnotherServer method. How would I achieve this?

EDIT: Answered in 7 minutes - thanks Lukas!

asked 28 Jun '11, 17:52

dmilor's gravatar image

dmilor
172
accept rate: 0%

edited 28 Jun '11, 18:16


Unfortunately, the SFTP protocol doesn't have a "copy" command and it doesn't even support server-to-server transfers, which could be used with FTP to achieve this.

However, SFTP runs over an SSH channel, which means it might be possible to take advantage of SSH remote exec functionality to execute commands at the server. This way, you might be able to execute commands such as "cp sourcepath targetpath" (on Unix-based servers) or "copy soucepath targetpath" (on Windows-based servers) to achieve what you need. Please check out the answer to Remote copy file - SFTP for sample code.

link

answered 28 Jun '11, 17:58

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.4k28
accept rate: 31%

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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

Tags:

×141

Asked: 28 Jun '11, 17:52

Seen: 551 times

Last updated: 28 Jun '11, 18:16