Post a reply

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

martin

Re: Spaces in File Name ftp get command not working

Does the file even exist?
Please, put ls command before the get command and post a log file.
marunachalam@...

Spaces in File Name ftp get command not working

Hi,

I tried adding double quotes for the files names and it still gives me the following error:


get "File_HQ_data_SourceGuestID_Email_2019_03_18 07_00_03"
Can't get attributes of file 'File__HQ_data_SourceGuestID_Email_2019_03_18 07_00_03'.
Could not retrieve file information


This is my code snippet:
var4 = File__HQ_data_SourceGuestID_Email_2019_03_18 07_00_03
winscp.com /nointeractiveinput /log=L:\ETLLOGS\FTP\%r%.log /command "option batch abort" "option confirm off" "option echo on" "open %var1%" "lcd %var2%" "cd /" "cd %var3%" "get ""%var4%""" "exit" >> %tmpdir%\%r%.ftpget
if %errorlevel% neq 0 GOTO :ERROR1
EXIT /B 0
:ERROR1
echo %DATE% %TIME% FA1 - %1 >> L:\ETLLOGS\FTP\LOGS\GETFAILEDATTEMPTS
Bob Whitehurst

Re: Anyone using c# to try to download a remote file with spaces in the name?

It's a customer's ftp server. I'll ask them what type of ftp server they are using. In the meantime, I worked around the problem by using the TransferOptions FileMask feature.
martin

Re: Anyone using c# to try to download a remote file with spaces in the name?

Bob Whitehurst wrote:

I'm calling the session.GetFiles() method from c#. The first parameter is remotePath which can be a path or a file. If a path, you download all the files in the path. If a file, you download the file. I created a "New Text Document.txt" file and copied it into my remote ftp directory under path yK and then tried to download it. I get => "Can't get attributes of file '/yk/New Text Document.txt. Could not retrieve file information. Invalid number of arguments MLST /yk/New Text Document.txt". Then I renamed the remote file to NewTextDocument.txt and it downloaded just fine. Has anyone overcome this obstacle?

Looks like a bug in your FTP server. What FTP server are you using?
Bob Whitehurst

Anyone using c# to try to download a remote file with spaces in the name?

I'm calling the session.GetFiles() method from c#. The first parameter is remotePath which can be a path or a file. If a path, you download all the files in the path. If a file, you download the file. I created a "New Text Document.txt" file and copied it into my remote ftp directory under path yK and then tried to download it. I get => "Can't get attributes of file '/yk/New Text Document.txt. Could not retrieve file information. Invalid number of arguments MLST /yk/New Text Document.txt". Then I renamed the remote file to NewTextDocument.txt and it downloaded just fine. Has anyone overcome this obstacle?
Guest

Excellent, works a treat. Thanks
martin

Re: Spaces in filenames...

See
https://winscp.net/eng/docs/commandline#syntax

I.e. the correct syntax is:

"c:\Program Files\winscp\winscp.com" /command "option batch abort" "option confirm off" "open ftp://password:username@server.com" "rm ""/Temp/File_to_delete.plp""" "exit"
Floatingshed

Spaces in filenames...

Hello,

I need to occasionally delete a remote file so I've written a simple gui that inserts the filename into a command line and executes it. This is my command line:

"c:\Program Files\winscp\winscp.com" /command "option batch abort" "option confirm off" "open ftp://password:username@server.com" "rm /Temp/File_to_delete.plp" "exit"

It works fine unless the filename has any spaces in it. In that case I get a file not found error, normally this is fixed by putting the whole filename and path in quotes, but it already is!

Any help much appreciated.