"Error code: 2" in simple PUT

Advertisement

ILL
Joined:
Posts:
5
Location:
Spain

"Error code: 2" in simple PUT

I am scripting this simple code
open test:password@194.224.XXX.YYY
put .\sincc.TXT
bye
But it doesn't work. WinSCP says
Error code: 2
sincc.TXT exists next to the WinSCP executable.

Why?
I will attach the log.

Thanks in advance. Sorry for my English.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: "Error code: 2" in simple PUT

A full error message is:
Cannot create remote file '/sincc.TXT'. ("No such file or directory.
Error code: 2
Error message from server: No such file."

The error comes from the server. It can have many reasons.

Were you able to upload any file using GUI?

Reply with quote

ILL
Joined:
Posts:
5
Location:
Spain

Re: "Error code: 2" in simple PUT

Thanks for the reply

I was not able to upload any file using WinSCP GUI (see attached), but I was able to upload any file using another GUI (like CoreFTP).

Subida a SFTP.JPG

Reply with quote

ILL
Joined:
Posts:
5
Location:
Spain

Re: "Error code: 2" in simple PUT

Attached. (private. There is no problem, is it?)
  • COREFTP.LOG (638 Bytes, Private file)

Reply with quote

Advertisement

ILL

Re: "Error code: 2" in simple PUT

Oh! The message "Error code 2 no such file" which is true but because I'm uploading, gave me a reason to prove one thing: if the file exists in the destination, it works the upload! However, this is just a patch, because it is normal that the file upload is not there, of course.

Reply with quote

ILL
Joined:
Posts:
5
Location:
Spain

Re: "Error code: 2" in simple PUT

Thanks for the reply again.

Already solved the incidence posted. It seemed to be something on the server and, as I think you were suspecting now, seemed to be some about versions, because we resolved with an update to the sftp server.

Greetings.

Sorry for my English.

Reply with quote

Advertisement

Pref
Joined:
Posts:
4

"Error code: 2" in simple PUT

Hi,

All of a sudden, I have experienced same error.
Usually, put was creating a folder if it didn't exist, worked like a charm for years.
Now, it is error 2.
If I manually create a folder on the server, and then just upload, all works.
I use simple script:
   "open sftp://login:password@domain.com/ -hostkey=""xxx"" -rawsettings PingType=2 FSProtocol=2 ProxyPort=1 SFTPMaxVersion=3" ^
 
   "put -nopreservetime ""N:\path_to_file\.htaccess"" /test2/" ^
   "put -nopreservetime ""N:\path_to_file\index.php"" /test2/" ^
   "put -nopreservetime ""N:\path_to_file\file?1?-*.pdf"" /test2/" ^
   "put -nopreservetime ""N:\path_to_file\file?1?-*.mp3"" /test2/" ^
   "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
Usually, it created /test2 folder, and put all files in it.
Does anybody know why it stopped working?
Cheers,
Piotr
Last edited by Pref on 2024-04-03 13:44; edited 1 time in total

Reply with quote

Pref
Joined:
Posts:
4

Re: "Error code: 2" in simple PUT

Hi @ILL,
Could you provide with more specific information on what was with your server, and what you needed to update?
Best,
Piotr

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: "Error code: 2" in simple PUT

@Pref: In general the put does not create the target directory. It actually might create them with some protocols. But it never creates them with SFTP.
If you have logs from before, I can check them to see what has changed.
But in general, you should create the target folder before then upload. Use the mkdir command:
https://winscp.net/eng/docs/scriptcommand_mkdir

Reply with quote

Pref
Joined:
Posts:
4

Re: "Error code: 2" in simple PUT

Martin, thanks a lot, it might be the cause: previously I used FTP only.
So far, mkdir works! Thank you!
Cheers,
Piotr

Reply with quote

Advertisement

You can post new topics in this forum