Empty directory listing

Advertisement

MichaelS
Guest

Empty directory listing

Hello,
I'm encountering a strange behaviour when FTPing to one of my system. I have a directory there, containing 3 text files. I successfully connect to the system via WinSCP GUI, but I do not see anything in the remote directory, like the remote directory is empty. I have written the following script to get all the files from the directory without the need to use the GUI – the script looks like this:

    "open ftp://username:password@IPaddress/ -rawsettings ProxyPort=0" ^
    "cd /brmsftp" ^
    "lcd ""I:\BRMS Rcy rpt\""" ^
    "mget -transfer=ascii *.*" ^
    "exit"
And the script retrieves nothing. This is in the WinSCP log file (I have removed some confidential information):
. 2022-05-20 08:28:44.231 Using FTP protocol.
. 2022-05-20 08:28:44.231 Doing startup conversation with host.
< 2022-05-20 08:28:44.231 Script: Starting the session...
> 2022-05-20 08:28:44.231 PWD
< 2022-05-20 08:28:44.246 257 "QGPL" is current library.
. 2022-05-20 08:28:44.246 Getting current directory name.
. 2022-05-20 08:28:44.246 Startup conversation with host finished.
< 2022-05-20 08:28:44.246 Script: Session started.
< 2022-05-20 08:28:44.246 Script: Active session: [1] user@IPaddress
> 2022-05-20 08:28:44.246 Script: cd /brmsftp
. 2022-05-20 08:28:44.246 Changing directory to "/brmsftp".
> 2022-05-20 08:28:44.246 CWD /brmsftp
< 2022-05-20 08:28:44.262 250-NAMEFMT set to 1.
< 2022-05-20 08:28:44.262 250 "/brmsftp" is current directory.
. 2022-05-20 08:28:44.262 Getting current directory name.
> 2022-05-20 08:28:44.262 PWD
< 2022-05-20 08:28:44.262 257 "/brmsftp" is current directory.
< 2022-05-20 08:28:44.262 Script: /brmsftp
> 2022-05-20 08:28:44.262 Script: lcd "I:\BRMS Rcy rpt\"
< 2022-05-20 08:28:44.262 Script: I:\BRMS Rcy rpt\
> 2022-05-20 08:28:44.262 Script: mget -transfer=ascii *.*
. 2022-05-20 08:28:44.262 Retrieving directory listing...
> 2022-05-20 08:28:44.262 TYPE A
< 2022-05-20 08:28:44.262 200 Representation type is ASCII nonprint.
> 2022-05-20 08:28:44.262 PASV
< 2022-05-20 08:28:44.262 227 Entering Passive Mode (IP and ports).
> 2022-05-20 08:28:44.262 LIST -a
. 2022-05-20 08:28:44.262 Connecting to IP and port ...
< 2022-05-20 08:28:44.278 550  Path does not exist: -a
. 2022-05-20 08:28:44.278 Could not retrieve directory listing
. 2022-05-20 08:28:44.278 LIST with -a failed, will try pure LIST
. 2022-05-20 08:28:44.278 Retrieving directory listing...
> 2022-05-20 08:28:44.278 TYPE A
< 2022-05-20 08:28:44.278 200 Representation type is ASCII nonprint.
> 2022-05-20 08:28:44.278 PASV
< 2022-05-20 08:28:44.293 227 Entering Passive Mode (IP and port).
> 2022-05-20 08:28:44.293 LIST
. 2022-05-20 08:28:44.293 Connecting to IP and port ...
< 2022-05-20 08:28:44.325 125 List started.
. 2022-05-20 08:28:44.325 Cannot parse line:
. 2022-05-20 08:28:44.325 userID         86255 25.04.22 15.15.45 *STMF      222504BRMSRCY.TXT
. 2022-05-20 08:28:44.325 Cannot parse line:
. 2022-05-20 08:28:44.325 userID          1162 25.04.22 15.15.45 *STMF      222504BRMSRCY2.TXT
. 2022-05-20 08:28:44.325 Data connection closed
. 2022-05-20 08:28:44.325 Unparsed listing:
. 2022-05-20 08:28:44.325 userID        114904 25.04.22 15.15.45 *STMF      222504BRMSBCK.TXT
 
. 2022-05-20 08:28:44.325 <Empty directory listing>
< 2022-05-20 08:28:44.340 250 List completed.
. 2022-05-20 08:28:44.340 Directory listing successful
. 2022-05-20 08:28:44.340 ..;D;0;1899-12-30T01:00:00.000Z;0;"" [0];"" [0];---------;0
< 2022-05-20 08:28:44.340 Script: No file matching '*.*' found. 
WinSCP and FileZilla have the exact same issue where I have an empty directory listing when using their GUI.
But when I FTP to the system with PowerShell, I can use the ls command, I can see the files, and can use mget to fetch all of them.

Could you please give me some advice where to look for errors? What does it mean 'Cannot parse line'?

Many thanks for advices.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,567
Location:
Prague, Czechia

Re: Empty directory listing

WinSCP (and obviously neither FileZilla) does not support the format of directory listing your server produces for LIST command. What kind of server is that? Can you attach a complete log?

By "FTP ... with PowerShell", I assume you actually mean plain old Windows command-line ftp client. It uses NLST command instead of LIST). The NLST produces just list of file names without any additional details. For trivial needs of Windows ftp, it's satisfactory, as ftp does not need to be able to tell files from folders, nor know file timestamps. But for GUI client (or scripting client that supports directory transfers and preserving of timestamps), it's far from enough.

Reply with quote

Guest

Re: Empty directory listing

martin wrote:

What kind of server is that? Can you attach a complete log?
It is an IBM i partition. OS based on DB2. I have dozens of these and this is the only one I can't fetch the files from. It is the only one I receive a 'Cannot parse line' from.
I'm not sure about uploading a complete log. I can try, but I need to take care about removing some sensitive information. Is there anything particular you'd want, or I should look for, please?

martin wrote:

By "FTP ... with PowerShell", I assume you actually mean plain old Windows command-line ftp client.
I actually mean Windows PowerShell, not CMD.

Reply with quote

Guest

Re: Empty directory listing

martin wrote:

So wouldn't site listfmt 1 help?
See https://winscp.net/eng/docs/faq_mainframe#path_ftp
As strange is may seem, using command namefmt I would normally use from one IBMi to another is not recognized by the server when trying WinSCP script:
> 2022-07-12 11:08:02.543 Script: namefmt 1
< 2022-07-12 11:08:02.543 Script: Unknown command 'namefmt'.
. 2022-07-12 11:08:02.543 Script: Failed
. 2022-07-12 11:08:02.543 Script: Exit code: 1
. 2022-07-12 11:08:02.559 Disconnected from server
I do not understand how is it possible (or how to say it), that apparently the files are there and WinSCP sees them, but the script says there is a kind of parsing error:
> 2022-07-12 12:43:57.094 LIST
. 2022-07-12 12:43:57.094 Connecting to address:10515 ...
. 2022-07-12 12:43:57.094 Cannot parse line:
. 2022-07-12 12:43:57.094 ID       86255 25.04.22 15.15.45 *STMF      222504BRMSRCY.TXT
. 2022-07-12 12:43:57.094 Cannot parse line:
. 2022-07-12 12:43:57.094 ID       1162 25.04.22 15.15.45 *STMF      222504BRMSRCY2.TXT
< 2022-07-12 12:43:57.094 125 List started.
. 2022-07-12 12:43:57.094 Data connection closed
. 2022-07-12 12:43:57.094 Unparsed listing:
. 2022-07-12 12:43:57.094 ID      114904 25.04.22 15.15.45 *STMF      222504BRMSBCK.TXT

. 2022-07-12 12:43:57.094 <Empty directory listing>
< 2022-07-12 12:43:57.132 250 List completed.
. 2022-07-12 12:43:57.132 Directory listing successful
. 2022-07-12 12:43:57.132 ..;D;0;1899-12-30T01:00:00.000Z;0;"" [0];"" [0];---------;0
< 2022-07-12 12:43:57.132 Script: No file matching '*.*' found.
. 2022-07-12 12:43:57.132 Copying 0 files/directories to local directory
I have played around the FTP target server attributes as you provided in the links, without success.

martin wrote:

Regarding the PowerShell: I understand that you are using PowerShell, not cmd, but you are running the plain old Windows ftp from the PowerShell, right?
Yes, that's right.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,567
Location:
Prague, Czechia

Re: Empty directory listing

The FTP command is site listfmt 1, not listfmt 1. And to call a raw FTP command in WinSCP script, you need to use the WinSCP call command.
call site listfmt 1
In your batch file, that you be this syntax:
    "call site listfmt 1" ^
(after the line with the open command)

Reply with quote

Advertisement

You can post new topics in this forum