FTP LIST command not working.

Questions about our File Management and Internet FTP plug-in
Locked
DaveJ
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am

FTP LIST command not working.

Post by DaveJ »

I have tried for days to get the fmSendFTPCommand "FTP" "LIST" "[FTPLIST]" working with both a Western Digital 'My Cloud' and a CentOS7 ftp server setup and neither will return a file list.
If I use Filezilla ftp client or a web browser it all works well with both FTP servers.
If I send a PASV command and then a LIST command the program freezes for a few minutes and then returns an error "Read timed out"
The Neobook FTP Client.pub also suffers the same problem, so now I know it is not my code.
Here is the log.

Code: Select all

Program started					
FTP Import Completed	Connecting to 192.168.1.150.				
Connected.					
<<- 220 Welcome					
->> USER test					
<<- 331 Please specify the password.					
->> PASS **********					
<<- 230 Login successful.					
->> FEAT					
<<- 211-Features:					
<<-  EPRT					
<<-  EPSV					
<<-  MDTM					
<<-  PASV					
<<-  REST STREAM					
<<-  SIZE					
<<-  TVFS					
<<-  UTF8					
<<- 211 End					
->> TYPE A					
<<- 200 Switching to ASCII mode.					
Starting FTP transfer					
->> PASV					
<<- 227 Entering Passive Mode (192	168	1	150	88	45).
->> LIST					
<<- 150 Here comes the directory listing.					
Transfer complete					
<<- 226 Directory send OK.					
->> PWD					
<<- 257 "/home/test"					
->> PWD					
<<- 257 "/home/test"					
->> CWD /					
<<- 250 Directory successfully changed.					
Starting FTP transfer					
->> PASV					
<<- 227 Entering Passive Mode (192	168	1	150	163	47).
->> LIST  -a					
<<- 150 Here comes the directory listing.					
Transfer complete					
<<- 226 Directory send OK.					
->> PWD					
<<- 257 "/"					
->> CWD /					
<<- 250 Directory successfully changed.					
Starting FTP transfer					
->> PASV					
<<- 227 Entering Passive Mode (192	168	1	150	243	54).
->> LIST  -a					
<<- 150 Here comes the directory listing.					
Transfer complete					
<<- 226 Directory send OK.					
->> CWD /					
<<- 250 Directory successfully changed.					
Starting FTP transfer					
->> PASV					
<<- 227 Entering Passive Mode (192	168	1	150	161	173).
->> LIST  -a					
<<- 150 Here comes the directory listing.					
Transfer complete	
Has anyone had the same problem?

Thanks
Dave J
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: FTP LIST command not working.

Post by Neosoft Support »

I'm getting the same error with the LIST command here. It may be that the data returned by the server is not being interpreted correctly by FM/FTP. I'll have to do some research to see if there is a solution.

As a workaround, you can try using the fmFileListToVar action instead which will return a list of files/folders in the current dir.
NeoSoft Support
DaveJ
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am

Re: FTP LIST command not working.

Post by DaveJ »

Thanks,
Good to know.
Look forward to a solution.
I will try your suggestion.

Thanks
DaveJ
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am

Re: FTP LIST command not working.

Post by DaveJ »

This is getting quite confusing now.
The 'fmFileListToVar' is only returning directory names, as soon as I move to a directory with just files, it returns nothing.
As both my CenstOS system and Western Digital NAS are both Linux based, I have setup a windows server box running IIS with FTP services. This setup returns both files and directories but if I use the following command
fmGetItemInfo "FTP" "Package.zip" "Size" "Plain" "[FTPsize]"
I get a 'file not found'.
If I run this command
fmSendFTPCommand "FTP" "SIZE Package.zip" "FTPsizex"
I get the size back ok.

I am basically trying to create an auto update program. I have created a file called 'package.zip' of which I compare the size on the ftp server to the size locally and if they are different I download the new file. A bit crude but good enough for my purpose. I just dont seem to be able to get many of the commands working.

Any ideas how I can do this?
Thanks
Dave J
DaveJ
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am

Re: FTP LIST command not working.

Post by DaveJ »

Just to ensure that I haven't done something silly, I have created a publication with just one button.

Code: Select all

fmConnectRemote "FTP" "192.168.1.8" "User=testaccount;Password=testaccount1#;Port=21;Passive=Yes;Timeout=60;InitialPath=;LogLimit=0;KeepAlive=0"
fmFileListToVar "FTP" "FullPath=No;IncludeFiles=Yes;IncludeFolders=No;SelectedOnly=No" "FTPResult"
fmFileExists "FTP" "Package.zip" "FTPFileExists"
fmSendFTPCommand "FTP" "SIZE Package.zip" "FTPsizex"
The resulting variables are;

Code: Select all

FTP.CurrentDir=/
FTP.FileMask=*.*
FTP.Log=Connecting to 192.168.1.8.
Connected.
<<- 220 Microsoft FTP Service
->> USER testaccount
<<- 331 Password required for testaccount.
->> PASS ***************
<<- 230 User logged in.
->> FEAT
<<- 211-Extended features supported:
<<-  LANG EN*
<<-  UTF8
<<-  AUTH TLS;TLS-C;SSL;TLS-P;
<<-  PBSZ
<<-  PROT C;P;
<<-  CCC
<<-  HOST
<<-  SIZE
<<-  MDTM
<<-  REST STREAM
<<- 211 END
->> TYPE A
<<- 200 Type set to A.
Starting FTP transfer
->> PASV
<<- 227 Entering Passive Mode (192,168,1,8,250,102).
->> LIST
<<- 125 Data connection already open; Transfer starting.
Transfer complete
<<- 226 Transfer complete.
->> PWD
<<- 257 "/" is current directory.
->> PWD
<<- 257 "/" is current directory.
->> PWD
<<- 257 "/" is current directory.
->> CWD /
<<- 250 CWD command successful.
Starting FTP transfer
->> PASV
<<- 227 Entering Passive Mode (192,168,1,8,250,103).
->> LIST  -a
<<- 125 Data connection already open; Transfer starting.
<<- 226 Transfer complete.
Transfer complete
->> CWD /
<<- 250 CWD command successful.
Starting FTP transfer
->> PASV
<<- 227 Entering Passive Mode (192,168,1,8,250,104).
->> LIST  -a
<<- 125 Data connection already open; Transfer starting.
<<- 226 Transfer complete.
Transfer complete
->> SYST
<<- 215 Windows_NT
->> TYPE A
<<- 200 Type set to A.
Connection established
->> PWD
<<- 257 "/" is current directory.
->> CWD 
<<- 250 CWD command successful.
Starting FTP transfer
->> PASV
<<- 227 Entering Passive Mode (192,168,1,8,250,105).
->> LIST  -a
<<- 125 Data connection already open; Transfer starting.
<<- 226 Transfer complete.
Transfer complete
->> SIZE Package.zip
<<- 213 11115152
->> PWD
<<- 257 "/" is current directory.
FTP.Status=Connected
FTP.TotalItems=2
FTPFileExists=False
FTPResult=MD5SUMS;Package.zip
FTPsizex=213
11115152

hpwNBVersion=585.2
As you can see fmFileListToVar lists Package.zip as a file but FMFileExists says it doesn't.
fmSendFTPCommand "FTP" "SIZE Package.zip" "FTPsizex" says it does exist because it can read its size.
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: FTP LIST command not working.

Post by Neosoft Support »

The fmFileExists does work, but you need to include a path along with the file's name. For example:

fmConnectRemote "FTP" ...
fmFileExists "FTP" "/httpdocs/Package.zip" "[FTPFileExists]"

The fmGetItemInfo works the same way. For example, to get the file's size you could do this:

fmConnectRemote "FTP" ...
fmGetItemInfo "FTP" "/httpdocs/Package.zip" "Size" "Plain" "[FTPSize]"

I've used "httpdocs" as the path here, but if your website is organized differently, then you may need to change this.
NeoSoft Support
DaveJ
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am

Re: FTP LIST command not working.

Post by DaveJ »

Hi Dave, I have sent an email to you.
My files were located in the root directory so there should have been no need for any further path statement.

Thanks
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: FTP LIST command not working.

Post by Neosoft Support »

Thanks for sending the sample pub file and for providing access to your server for testing. I was able to reproduce the problem you described with the file list. After some research and experimentation, I was able to find a solution. I sent you a file via email to test. Hopefully, it wasn't eaten by your Spam filter.

Currently FM/FTP executes the LIST command with an extra parameter "-a" which is supposed to tell the server to include hidden files
(like .htaccess) in the list of files. This works fine with Unix-based servers, but apparently isn't supported by Windows-based servers like yours. Removing the "-a" seems to have fixed the problem, but you can confirm this with the files I sent.
NeoSoft Support
DaveJ
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am

Re: FTP LIST command not working.

Post by DaveJ »

Got the files and all looks good.
All the functions seem to be working now.
I will test further.

Many thanks for the quick fix.

Dave J
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: FTP LIST command not working.

Post by Neosoft Support »

You're welcome. Let us know the final results of your testing.
NeoSoft Support
DaveJ
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am

Re: FTP LIST command not working.

Post by DaveJ »

Hi Dave,
Sorry to take so long but I think there still may be some problems.
All is well with the Microsoft FTP server but the Western Digital NAS seems to still have problems (Linux/Unix based).

Code: Select all

fmConnectRemote "FTP" "192.168.1.30" "User=user;Password=password;Port=21;Passive=No;Timeout=60000;InitialPath=data;LogLimit=0;KeepAlive=0"
fmShowFileBrowser "FTP" "Rectangle1"
fmFileListToVar "FTP" "FullPath=Yes;IncludeFiles=Yes;IncludeFolders=Yes;SelectedOnly=No" "FTPResult"
fmFileExists "FTP" "Package.zip" "[FTPFileExists]"
fmGetItemInfo "FTP" "Package.zip" "Size" "Plain" "[FTPSize]"
fmSendFTPCommand "FTP" "SIZE Package.zip" "FTPsizex"
The rectangle is showing the correct files, fmFileListToVar works and the fmSendFTPCommand "FTP" "SIZE Package.zip" works but the fmFileExists reports false and fmGetItemInfo says file not found.
I would be more than happy to set up a test server account if you need it.
Thanks

Dave J
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: FTP LIST command not working.

Post by Neosoft Support »

I don't know why the Western Digital NAS wouldn't work when other servers do. You would think they would all be compatible, but I guess not. Since we don't have a WD NAS server, I will need to have access to yours in order to troubleshoot. I won't be able to look at this until Friday however.
NeoSoft Support
Locked