No such file or directory error after lost connection and reconnect

Advertisement

ThomasP.
Joined:
Posts:
2
Location:
Germany

No such file or directory error after lost connection and reconnect

Hi,

I have a problem with my cmd script.
The script will be executed by an ETL-process in a loop. In each loop interation the script just downloads one .txt files from the server (Filename will be graped from Database, ETL Process builds and executes the script for one file). Sometimes everything goes fine but sometimes the connection gets lost. When connection gets lost the script is reconnecting and trying to dowload the file again but at this point i always get the error "550 CWD cmd failed : EDC5129I No such file or directory. (errno2=0x05190050)"?
I can not explain why directory will not be found... If I retry execution the directory will be found and the file gets downloaded...
Can anybody give me a hint how to solve this problem?

code of Script:
echo open ftp://Xexample:DIAexample@99.99.999.1:21 -explicit -hostkey="[myHostKey]" -passive=on >>%CMMSCRIPTS%\getDIAZ.tmp
echo ascii >>%CMMSCRIPTS%\getDIAZ.tmp
set FilePath=%1
echo CD //%FilePath:~0,16% >>%CMMSCRIPTS%\getDIAZ.tmp
echo GET %FilePath:~17,8% %CMMROOT%\Inputdaten\J_DIAZ\getdiaz.txt >>%CMMSCRIPTS%\getDIAZ.tmp
echo close  >>%CMMSCRIPTS%\getDIAZ.tmp
echo exit >>%CMMSCRIPTS%\getDIAZ.tmp
 
%CMMSCRIPTS%\WinSCP-5.15.3-Portable\winscp.com /ini=nul /log=%CMMSCRIPTS%\getDiaz.log /script=%CMMSCRIPTS%\getDIAZ.tmp

Further information:
WinSCP version 5.15.3-portable
Win-Server 2016 Standard 64-bit
Transfer Protocol: FTP

Log file:
getDiaz.log (Shows 3 executions of the script, 2 Successful, 1 Failed with error "550 CWD cmd failed : EDC5129I No such file or directory. (errno2=0x05190050)")
Description: Shows 3 executions of the script, 2 Successful, 1 Failed with error "550 CWD cmd failed : EDC5129I No such file or directory. (errno2=0x05190050)"

Reply with quote

Advertisement

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

Re: No such file or directory error after lost connection and reconnect

Thanks for your report and sorry for my late answer.
It took me while to investigate the logs.
I see that WinSCP tries this when trying to restore the working directory from before the connection loss:
CWD /'XZH081P.Z.TDF42C.'
That does not work.
What should it do instead? Would this work?
CWD 'XZH081P.Z.TDF42C.'

Reply with quote

ThomasP.
Joined:
Posts:
2
Location:
Germany

Re: No such file or directory error after lost connection and reconnect

Hi Martin,
thanks 4 your reply and spending the time to review my problem!
I already recognized that the CWD after a reconnect is wrong. But how to influence the CWD after a reconnect? Why it is wrong after a reconnect and not the same as before?
Before the reconnect the CWD is //XZH081P.Z.TDF42C which is correct.

Conclusion:
:: Before Reconnect
1. open the connection
2. "'XS99998.'" is working directory.
3. Script: CD //XZH081P.Z.TDF42C
4. Changing directory to "//XZH081P.Z.TDF42C".
5. CWD //XZH081P.Z.TDF42C
6. GET ..... -> file will be downloaded successfully

:: after reconnect
1. reconnect
2. "'XS99998.'" is working directory.
3. Changing directory to "/'XZH081P.Z.TDF42C.'".
4. CWD /'XZH081P.Z.TDF42C.'
5. CWD cmd failed : EDC5129I No such file or directory.
6. GET ........ -> Downloading file failed.

Reply with quote

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

Re: No such file or directory error after lost connection and reconnect

Before reconnect is works, because you have an explicit cd command.
After reconnect, WinSCP tries to restore what it (incorrectly) believes was the current working directory: /'XZH081P.Z.TDF42C.'
Instead, WinSCP might use the path that the server provided:
257 "'XZH081P.Z.TDF42C.'" is working directory.
That's why I'm asking if this would work:
CWD 'XZH081P.Z.TDF42C.'
It is hard to make WinSCP do:
CWD //XZH081P.Z.TDF42C
It might seem easy with your simple script. But a more complex script might do multiple cd commands with relative paths and WinSCP would have to replay them all.

Reply with quote

Advertisement

You can post new topics in this forum