Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Muffinz

[SOLVED] - Error code: 2 - Error message from server: No such file

Hi,

I'm trying to transfer some files over SFTP with a certificate and I'm getting this error message in the log:
. 2016-12-27 11:10:59.283 File: '\\Local\Path\Remove_ME.txt' [2016-12-27T09:13:02.320Z] [0]
. 2016-12-27 11:10:59.289 Copying "\\Local\Path\Remove_ME.txt" to remote directory started.
. 2016-12-27 11:10:59.289 Binary transfer mode selected.
. 2016-12-27 11:10:59.289 Opening remote file.
> 2016-12-27 11:10:59.289 Type: SSH_FXP_OPEN, Size: 48, Number: 259
< 2016-12-27 11:10:59.297 Type: SSH_FXP_STATUS, Size: 29, Number: 259
< 2016-12-27 11:10:59.297 Status code: 2, Message: 259, Server: No such file, Language: 
> 2016-12-27 11:10:59.298 Type: SSH_FXP_LSTAT, Size: 32, Number: 519
< 2016-12-27 11:10:59.306 Type: SSH_FXP_STATUS, Size: 29, Number: 519
< 2016-12-27 11:10:59.306 Status code: 2, Message: 519, Server: No such file, Language: 
* 2016-12-27 11:10:59.306 (ETerminal) No such file or directory.
* 2016-12-27 11:10:59.306 Error code: 2
* 2016-12-27 11:10:59.306 Error message from server: No such file
. 2016-12-27 11:10:59.306 Asking user:
. 2016-12-27 11:10:59.306 Cannot create remote file '/RemotePath/Remove_ME.txt'. ("No such file or directory.
. 2016-12-27 11:10:59.306 Error code: 2
. 2016-12-27 11:10:59.306 Error message from server: No such file")
< 2016-12-27 11:10:59.306 Script: Cannot create remote file '/RemotePath/Remove_ME.txt'.
< 2016-12-27 11:10:59.307 Script: No such file or directory.
< 2016-12-27 11:10:59.307 Error code: 2
< 2016-12-27 11:10:59.307 Error message from server: No such file
* 2016-12-27 11:10:59.307 (EScpSkipFile) Cannot create remote file '/RemotePath/Remove_ME.txt'.
* 2016-12-27 11:10:59.307 No such file or directory.
* 2016-12-27 11:10:59.307 Error code: 2
* 2016-12-27 11:10:59.307 Error message from server: No such file
. 2016-12-27 11:10:59.307 Script: Failed

It's working with the GUI and other applications as PSFTP.exe (from PuTTY) and FileZilla.
I've also searched this forum but I haven't found the answer.

This is my script:
# Get today's date and format it as ddMMyyyy_HHmm (exampel 27122016_1109)
$Date = Get-date -Format ddMMyyyy_HHmm
 
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
 
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "HostName"
    UserName = "UserID"
    SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
    SshPrivateKeyPath = "\\Path\To\Key.ppk"
}
 
$session = New-Object WinSCP.Session
$session.SessionLogPath = "\\Path\To\Uploaded_$Date.log"
$sessionOptions.SshPrivateKeyPassphrase = "Password"
 
# Connect
$session.Open($sessionOptions)
 
# Your code
$localPath = "\\Loac\Path\*"
$remotePath = "/RemotePath/"
 
# Upload files, collect results
$transferResult = $session.PutFiles($localPath, $remotePath)
 
Write-Host ("Upload succeeded")
       
# Disconnect, clean up
$session.Dispose()

Thank you in advance!

P.S This is the old thread if needed: https://winscp.net/forum/viewtopic.php?t=24255

Solution
The folder path are case sensitive which my college pointed out and after I change that it worked.
You learn something new everyday.