0 votes
by (280 points)
edited

The file has been uploaded OK with SFTP. I can see it with the directory listing.

Lets say the file is RebexTest.txt. Once uploaded, I need to change it to Test.txt.

So, I tried:

oSftp.Rename(cRemoteDirectory + "/RebexTest.txt", cRemoteDirectory + "/Test.txt")

But, this keeps getting an error on file not found.

In order to rename a file, do I have to change directory first and simply do:

oSftp.Rename("RebexTest.txt", "Test.txt")

Because, your help shows that we need to pass a full path for the From and To.

Please, advise.

Applies to: Rebex SFTP

4 Answers

0 votes
by (58.9k points)
edited

Please create log using the LogWriter property of the Sftp object as described in this article. Please post the log of the file upload and the renaming which fails. Alternatively you can send the log to support@rebex.net.

0 votes
by (280 points)
edited

First of all, your documentation mentions the path but that need to be adjusted. It is based on the current location. So, if I am standing in a current directory, I should not provide the path but only from that point. So, having said that, if the directory I wish to rename the file is the one I am currently in, I only have to provide the file name.

IAC, this still does not work. See this partial log. You can see that after the upload, the file is there. You can also see that your Rename() method is trying to rename the file exactly as it was uploaded. But, there is an error:

2012-06-21 11:22:48.622 INFO Sftp(7)[1] Command: SSH_FXP_REALPATH (1, '.')
2012-06-21 11:22:48.731 INFO Sftp(7)[1] Response: SSH_FXP_NAME (1, 1 item)
2012-06-21 11:22:48.731 INFO Sftp(7)[1] Info: Current directory is '/'.
2012-06-21 11:22:48.731 INFO Sftp(7)[1] Command: SSH_FXP_REALPATH (2, '/FirstDirectory/seconddirectory/')
2012-06-21 11:22:48.825 INFO Sftp(7)[1] Response: SSH_FXP_NAME (2, 1 item)
2012-06-21 11:22:48.825 INFO Sftp(7)[1] Command: SSH_FXP_STAT (3, '/FirstDirectory/seconddirectory')
2012-06-21 11:22:48.934 INFO Sftp(7)[1] Response: SSH_FXP_ATTRS (3)
2012-06-21 11:22:49.012 INFO Sftp(7)[4] Command: SSH_FXP_STAT (4, '/FirstDirectory/seconddirectory')
2012-06-21 11:22:49.121 INFO Sftp(7)[4] Response: SSH_FXP_ATTRS (4)
2012-06-21 11:22:49.152 INFO Sftp(7)[4] Command: SSH_FXP_STAT (5, '/FirstDirectory/seconddirectory/RebexTest.txt')
2012-06-21 11:22:49.277 INFO Sftp(7)[4] Response: SSH_FXP_STATUS (5, 2, 'File not found')
2012-06-21 11:22:49.293 INFO Sftp(7)[4] Command: SSH_FXP_OPEN (6, '/FirstDirectory/seconddirectory/RebexTest.txt', 26)
2012-06-21 11:22:49.402 INFO Sftp(7)[4] Response: SSH_FXP_HANDLE (6, 0x31)
2012-06-21 11:22:49.932 DEBUG Sftp(7)[4] Command: SSH_FXP_WRITE (7, 0x31, 0, 28672 bytes)
2012-06-21 11:22:50.494 DEBUG Sftp(7)[4] Command: SSH_FXP_WRITE (8, 0x31, 28672, 28672 bytes)
2012-06-21 11:22:50.541 DEBUG Sftp(7)[4] Command: SSH_FXP_WRITE (9, 0x31, 57344, 2991 bytes)
2012-06-21 11:22:50.541 DEBUG Sftp(7)[4] Response: SSH_FXP_STATUS (7, 0, 'OK')
2012-06-21 11:22:50.759 DEBUG Sftp(7)[4] Response: SSH_FXP_STATUS (8, 0, 'OK')
2012-06-21 11:22:50.759 DEBUG Sftp(7)[4] Response: SSH_FXP_STATUS (9, 0, 'OK')
2012-06-21 11:22:50.759 INFO Sftp(7)[4] Command: SSH_FXP_CLOSE (10, 0x31)
2012-06-21 11:22:50.837 INFO Sftp(7)[4] Response: SSH_FXP_STATUS (10, 0, 'Ok')
2012-06-21 11:22:51.071 INFO Sftp(7)[1] Command: SSH_FXP_RENAME (11, '/FirstDirectory/seconddirectory/RebexTest.txt', '/FirstDirectory/seconddirectory/Test.txt')
2012-06-21 11:22:51.180 INFO Sftp(7)[1] Response: SSH_FXP_STATUS (11, 2, 'File not found')
2012-06-21 11:22:51.196 ERROR Sftp(7)[1] Info: Rebex.Net.SftpException: No such file; File not found.
   at gbMKS.PEQpz.eCVvJZ(1dRwomZ , Type )
   at Rebex.Net.Sftp.Rename(String fromPath, String toPath)
0 votes
by (280 points)
edited

This seems like another GlobalSCAPE compability issue.

If I take a look at this example, found on your site:

client.Rename("/New/file.txt", "/Done/file.txt")

This is exactly what I am doing. I also avoiding changing directory. So, I am located at the root when I execute that command. This is not a factor. It is always file not found.

I also tried to put everything in lowercase. This is also not a factor.

I believe something is not compliant with GlobalSCAPE for the rename functionality of your component.

Please, advise.

by (147k points)
edited

Actually, we run our automated SFTP tests against GlobalScape EFT Server and have not encountered this issue. If it's indeed a GlobalScape issue, it only manifests itself under specific circumstances.

Have you tried using any third-party SFTP clients to rename the file? Judging from the log, I guess they would fail as well and this would confirm it's a server issue. Try PuTTY's psftp.exe utility or Filezilla, for example.

0 votes
by (280 points)
edited

I tried with Filezilla and it returns the same message:

Error: mv /MyDirectory1/MyDirectory2/RebexTest.txt /MyDirectory1/MyDirectory2/Test.txt: no such file or directory

So, it seems they have applied a restriction that forbids renaming a file on their server. We have sent them a message to rectify the privileges.

...