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 filenames

Adding quotes looks like a lame workaround for a bug in their server that might work with very trivial FTP clients that more-or-less pass the commands unmodified to the FTP server, without trying to understand what the commands do. That cannot work with an advanced FTP client, like WinSCP, which needs to understand what the command do.

If there's sufficient demand, I might implement some compatibility mode for Ipswitch.

Though it would be better if they fix their server, obviously :)
kbaxreno

Re: Spaces in filenames

@martin: Hello.
Ipswitch FTP server.
I found on the Ipswitch site a message about needing to put filenames with spaces in quotes. When I place single or double quotes around the string the getfile() command fails with this error:
Can't get attributes of file '"./BED and BREAKFAST.jpg"'.
File or folder '"./BED and BREAKFAST.jpg"' does not exist.

The error is the same for a file with spaces as a file without.

Am I wrapping in quotes incorrectly? I am using VB.NET
Dim quote As String = Strings.Chr(34)
Dim FileToGet As String = strRPath & fileInfo.Name
Dim FileToGet2 As String = quote & FileToGet & quote
session.GetFiles(FileToGet2, localPath & strFilePrepend & fileInfo.Name).Check()

Thanks for any ideas.
martin

Re: Spaces in filenames

The MLST /users/Kens/BED and BREAKFAST.jpg is the correct command to use. So as with @BobWhitehurst above, it seem to be a bug in the FTP server. What FTP server is that?
kbaxreno

Spaces in filenames

I too am having an issue with spaces in filenames.

Files without spaces work fine:
2023-01-13 12:06:39.327 Listing file "./abbotNcostello.png".
. 2023-01-13 12:06:39.327 Retrieving file information...
> 2023-01-13 12:06:39.327 MLST /users/Kens/abbotNcostello.png
< 2023-01-13 12:06:39.346 250-MLST listing for /users/Kens/abbotNcostello.png
< 2023-01-13 12:06:39.346     size=31824;type=file;create=20230113114513;modify=20151007114217; abbotNcostello.png
< 2023-01-13 12:06:39.347 250 MLST end
. 2023-01-13 12:06:39.347     size=31824;type=file;create=20230113114513;modify=20151007114217; abbotNcostello.png
. 2023-01-13 12:06:39.347 Retrieving file information successful
. 2023-01-13 12:06:39.347 abbotNcostello.png;-;31824;2015-10-07T11:42:17.000Z;4;"" [0];"" [0];---------;0
. 2023-01-13 12:06:39.347 Copying 1 files/directories to local directory "D:\" - total size: 31,824
. 2023-01-13 12:06:39.347   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask: xferabbotNcostello.png
. 2023-01-13 12:06:39.347   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; EncryptNewFiles: Yes; ExcludeHiddenFiles: No; ExcludeEmptyDirectories: No; InclM: ; ResumeL: 0
. 2023-01-13 12:06:39.347   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2023-01-13 12:06:39.347 File: '/users/Kens/abbotNcostello.png' [2015-10-07T11:42:17.000Z] [31824]
. 2023-01-13 12:06:39.348 Copying "/users/Kens/abbotNcostello.png" to local directory started.
. 2023-01-13 12:06:39.348 Binary transfer mode selected.
. 2023-01-13 12:06:39.348 Starting download of /users/Kens/abbotNcostello.png
> 2023-01-13 12:06:39.348 TYPE I
< 2023-01-13 12:06:39.350 200 Transfer mode set to BINARY
> 2023-01-13 12:06:39.350 PASV
< 2023-01-13 12:06:39.352 227 Entering Passive Mode (10,).
> 2023-01-13 12:06:39.353 RETR abbotNcostello.png
. 2023-01-13 12:06:39.353 Connecting to 10.137.200.61:55978 ...
< 2023-01-13 12:06:39.357 150 Downloading in BINARY file abbotNcostello.png (31824)
< 2023-01-13 12:06:39.360 226 Transfer completed
. 2023-01-13 12:06:39.361 Data connection closed
. 2023-01-13 12:06:39.361 Preserving timestamp [2015-10-07T11:42:17.000Z]
. 2023-01-13 12:06:39.362 Download successful

Filenames with spaces fail:
. 2023-01-13 12:08:54.193 Retrieving file information...
> 2023-01-13 12:08:54.193 MLST /users/Kens/BED and BREAKFAST.jpg
< 2023-01-13 12:08:54.195 501 Invalid number of arguments MLST /users/Kens/BED and BREAKFAST.jpg
. 2023-01-13 12:08:54.195 Could not retrieve file information
< 2023-01-13 12:08:54.195 Script: Can't get attributes of file './BED and BREAKFAST.jpg'.
< 2023-01-13 12:08:54.195 Could not retrieve file information
 
< 2023-01-13 12:08:54.195 Invalid number of arguments MLST /users/Kens/BED and BREAKFAST.jpg
. 2023-01-13 12:08:54.196 Script: Failed
> 2023-01-13 12:33:27.868 Script: exit

Thanks
Ken
martin

Re: Spaces in File Name ftp get command not working

@marunachalam: 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?

@BobWhitehurst: 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.