CMD Script for FTP Upload - Directory Listening issue

Advertisement

Matthias
Joined:
Posts:
4
Location:
Germany

CMD Script for FTP Upload - Directory Listening issue

Hello,
we are using a script in combination with WinSCP. It is running fine. WinSCP is a very good tool, great work!
But we have an issue with too much datatransfer. WinSCP is asking the FTP for "Directory Listening" and we would like to deactivate this functionality.
More and more data will be uploaded to the FTP server and the datatransfer is increasing.

Is there any possiblity to avoid this Directory Listening and asking the FTP after every connection for the complete contant of the folder/share?

Thank you very much in advance.
Matthias

Reply with quote

Advertisement

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

Re: CMD Script for FTP Upload - Directory Listening issue

How are you using WinSCP? For download or upload? Show us your script. Post a log file.

Reply with quote

Matthias
Joined:
Posts:
4
Location:
Germany

Hi,
thanks for your support.
We are using WinSCP for Upload via 4G mobile connection.

We use a very simple configuration-file and open it with a ".bat" script every 5 minutes.
Here the most important part out of the ".bat"-file:
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /ini=nul /script="D:\USER\FTP-Upload\config.txt

open ftp://user:pw@ip
put -resume -neweronly D:\FTP-Data\*.* /
exit
We never had issues with WinSCP, but in the current case it seems that we have a very special FTP server. The FTP owner told us, that we have to turn off "Directory Listening" to reduce the data transfer via 4G mobile net.

I could currently not provide a log file. But I will try to do it soon.
Do you have any hints or solutions for us?
Thank you very much.

Matthias

Reply with quote

Matthias
Joined:
Posts:
4
Location:
Germany

Hi Martin,
thank you very much for your answer.
It sound that there is no special funktion avaiable to deactivate the "Directory listing".
Due to the mobile data connection it could happen that we lose the internet connection during a upload process. For that I think it should be a must to use this comment "-neweronly" to overwrite existing data on the FTP server which were not fully transmitted/uploaded.

Do you have any idea how we could be sure that a file was uploaded successfull (to 100%) without creating too much traffic (caused maybe by this Directory listing) ?

By the way: We tested another script time based, but have the same issues here.
".bat"
@echo off
:start
cls
echo FTP-Upload Process
for /F %%i in ('dir /b "D:\-FTP-DATEN-\*.*"') do (
   echo Found new data for upload:
   echo %%i
   "C:\Program Files (x86)\WinSCP\winscp.com" /script=ftp.txt /parameter %%i
)
timeout 60
goto start
This .bat-script will start a upload process for every file which is included in the mentioned folder and start again after 60 seconds.

ftp.txt
option reconnecttime 30
option confirm off
option batch on
option failonnomatch on
open ftp://user:pw@server
rm "%1%"
put D:\-FTP-Data-\"%1%" / -delete -resume
echo Upload process successful
exit

I was playing with some parameters such as confirmation, batch and failonnomatch without seeing anything being better for our use case.
I think the "rm" function will also ask for the content of the FTP server and will create this traffic (Directory listing). I am right ???

Thank you

Reply with quote

Advertisement

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

1) Your new batch file uploads all files from the local source folder. If you want to upload all files, you do not need to use the -neweronly switch and WinSCP won't have to do the listing.

2) With your new script, the listing is caused by the -resume switch. You should not use -resume switch, unless you explicitly want to resume a previously broken transfer.

Reply with quote

Matthias
Joined:
Posts:
4
Location:
Germany

Hi Martin,
thank you very much for you detailed answer.
We are using a mobile connection and it could happen that the upload will be interrupted by a connection break (mobile net error etc).
In this case we want to sure that this damaged file on the FTP server will be replaced or resumed.

What I understood is that we will only delete the original file on the computer after the transfer was successful. What will happen after we losed the internet connection (mobile connection) with a file which was not completly transfered? Will WinSCP overwrite/replace the not complete one on the FTP server automatically without using "-resume" or "-neweronly" ?

If that works and we will not create this listing traffic, then it could be the solution for our issue.

Thank you very much

Reply with quote

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

Matthias wrote:

What will happen after we losed the internet connection (mobile connection) with a file which was not completly transfered? Will WinSCP overwrite/replace the not complete one on the FTP server automatically without using "-resume" or "-neweronly" ?
WinSCP by default reconnects and resumes the transfer. While resuming the transfer, it might need to do the listing to check for the partially transferred file.

Reply with quote

Advertisement

You can post new topics in this forum