Archived Forum Post

Index of archived forum posts

Question:

"No such file" error when using OpenFile with createTruncate

Jun 23 '16 at 09:32

I'm trying to create or truncate a file on the server (original code in FoxPro), but I'm getting the following response. I had changed the disposition to "createTruncate,deleteOnClose" when this started, and I removed deleteOnClose back out, but I am still receiving this message:

SftpVersion: 3
sftpOpenFile:
remotePath: (IP address cleared for security)/FTPTEST.TXT
access: readWrite
createDisposition: createTruncate
v3Flags: 0x1b
Sent FXP_OPEN
StatusResponseFromServer:
Request: FXP_OPEN
InformationReceivedFromServer:
StatusCode: 2
StatusMessage: No such file
Actual code is as follows:
lcTargetFile = lcServerName + lcFoldername + "FTPTEST.TXT"
oSFTP.CONNECT(lcServerName,lnFTPPort)
oSFTP.AuthenticatePW(lcServerUID, lcServerPwd)
oSFTP.InitializeSFTP()
lnHandle = oSFTP.OpenFile(lcTargetFile,"readWrite","createTruncate")
My handle at this point is an empty string, and the LastErrorText returns the above. Any hints or help would be greatly appreciated!


Answer

The remote file path argument to OpenFile should be a relative path from the HOME directory of the SSH/SFTP user account. You probably don't want the server name in the path, and you probably don't want the path to begin with "/" (which would specify an absolute path on the remote server).


Answer

When a customer under support provides me with a login for such a problem, the first thing I do is to get my bearings -- immediately after authenticating, I run a snippet of code that fetches the HOME directory listing and shows the entries (files/sub-directories) that are present. If they don't match what I would expect to see, then...