"get" fails - no file: Can't get attributes of file / No such file or directory. / Error code: 2

Advertisement

fxdwg99
Joined:
Posts:
3

"get" fails - no file: Can't get attributes of file / No such file or directory. / Error code: 2

WinSCP get fails when there is no file and doesn’t continue to the exit command. I’m using command lines. (code listed below the examples). If I use a mget with an * in the file name it does end cleanly.

WinSCP: 5.17.10 (build 11087)
Windows Server 2019
SFTP
Scripting/automation

Logs with get:
F:\ecs>"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script="F:\ecs\z-GXS_test.txt"
echo            on
open sftp:// ******:***@FTP.xxx.com/ -hostkey="ssh-rsa 1024 4Q18VXXv3xw0xCrhpJVtIhqANlUrOf924HYGORyq0LI=" -timeout=300 -rawsettings CacheDirectories=0 CacheDirectoryChanges=0 EOLType=1
Searching for host...
Connecting to host...
Authenticating...
Using username "******".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] ******@FTP.xxx.com
cd from_cass
/from_cass
get MDBDATAAA.TXT f:\edi\ediprd\xlate\mbx\ck02521\recv\don_cassmthly.txt
Can't get attributes of file 'MDBDATAAA.TXT'.
No such file or directory.
Error code: 2
Error message from server (en): No such file.

F:\ecs>
Logs with mget:

I tried using an mget and is doesn’t fail when there is no file. It executes the exit at the end.
F:\ecs>"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script="F:\ecs\z-GXS_test.txt"
echo            on
open sftp://******:***@FTP.cassinfo.com/ -hostkey="ssh-rsa 1024 4Q18VXXv3xw0xCrhpJVtIhqANlUrOf924HYGORyq0LI=" -timeout=300 -rawsettings CacheDirectories=0 CacheDirectoryChanges=0 EOLType=1
Searching for host...
Connecting to host...
Authenticating...
Using username "******".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] ******@FTP.xxx.com
cd from_cass
/from_cass
mget MDBDATAAA.TXT* f:\edi\ediprd\xlate\mbx\ck02521\recv\don_cassmthly.txt
No file matching 'MDBDATAAA.TXT*' found.
exit

F:\ecs>
I’m on a Windows platform. We execute a bat file that calls the command lines:
z-GXS_sFTP_test.bat:
echo on
"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script="F:\ecs\z-GXS_test.txt"
Command lines with are in z-GXS_test.txt:
This version is using get:
option echo on
open sftp://cs011900:xxxxxx@FTP.xxxxxx.com/ -hostkey="ssh-rsa 1024 4Q18VXXv3xw0xCrhpJVtIhqANlUrOf924HYGORyq0LI=" -timeout=300 -rawsettings CacheDirectories=0 CacheDirectoryChanges=0 EOLType=1
cd from_cass
get MDBDATAAA.TXT f:\edi\ediprd\xlate\mbx\ck02521\recv\don_cassmthly.txt
exit
This version is using mget:
option echo on
open sftp://cs011900:xxxxxx@FTP.xxxxxx.com/ -hostkey="ssh-rsa 1024 4Q18VXXv3xw0xCrhpJVtIhqANlUrOf924HYGORyq0LI=" -timeout=300 -rawsettings CacheDirectories=0 CacheDirectoryChanges=0 EOLType=1
cd from_cass
mget MDBDATAAA.TXT* f:\edi\ediprd\xlate\mbx\ck02521\recv\don_cassmthly.txt
exit

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
37,181
Location:
Prague, Czechia

Re: "get" fails - no file: Can't get attributes of file / No such file or directory. / Error code: 2

That's the expected behavior.
What do you want to achieve?

Btw, note that there's no real mget in WinSCP. It's just an alias for get. They behave the same.

Reply with quote

fxdwg99
Joined:
Posts:
3

Re: "get" fails - no file: Can't get attributes of file / No such file or directory. / Error code: 2

I guess my main concern is the session closing cleanly? I don’t want to leave sessions hanging open. It never executes the exit at the end.

Yes I tested and see get and mget both can use wildcards.

This is where the other part of the question comes in. We converted our native Windows FTP to WinSCP SFTP.

In native FTP we could have more than one get in a single session. But with WinSCP failing and stopping on the first file it can’t find the other get do not execute. I had to break our one native FTP session of three get into three separate WinSCP sessions.

It looks like if we do a get with a specific file name and the file is not there WinSCP throws an error and just quits. If there other command for the session they are not executed. And the exit command at the end is not executed.

If we do a get with a wildcard and there is no file it continues on to the next command including the exit at the end.

To your other question … what would I like to achieve? It would be great if when a get on a specific file name is not found don’t end the session, go to the next command … like a get with a wildcard does.

Example of a session that does two get with a wildcards. There are no files to pull but the session goes to the second get and finally executes the exit:
cd DON_TAYLOR_TEST
/home/ftp/DON_TAYLOR_TEST
get * C:\tmp\WinSCP_test\get_data_here\
No file matching '*' found.
get * C:\tmp\WinSCP_test\get_data_here\
No file matching '*' found.
exit

C:\tmp\
Example of a session that does two get for a specific files name. The first get finds no files. The session ends and does not execute the second get or the exit:
cd DON_TAYLOR_TEST
/home/ftp/DON_TAYLOR_TEST
get don_test-1.txt C:\tmp\WinSCP_test\get_data_here\
Can't get attributes of file 'don_test-1.txt'.
No such file or directory.
Error code: 2
Error message from server: No such file

C:\tmp\

Reply with quote

Advertisement

You can post new topics in this forum