Sysax Product Forums / Sysax FTP Automation / General Discussion / ftpgetlist remote can not read directory.
Posted:  16 Feb 2010 10:46
Hi,
I'm trying to use ftp automation to get files from our remote unix systems. But ftpgetlist returns nothing.
Below it is seen my script and log.
#******************************************************************************

#  Script name : Ulus178.fscr

#  Description : Downloading items (files or folders) from remote to local host.

#******************************************************************************

#initialize variables
setvar ~server_address, "172.16.0.178";
setvar ~server_port, 21;
setvar ~login_name, "Admin";
setvar ~login_password, "Admin123";
setvar ~remote_path, "/swpkg_a/webct/data/";
setvar ~local_path, "c:\\logs";
setvar ~remote_fileformat, "*.*";

# setduperules function sets the rules to use if at the time of file transfer a duplicate file(a file with the same name
# as the file that is transferred) exists in the destination path. Before transferring the file the file that is to be transferred is
# compared with the file that already exists in the destination path. 1st argument('bysize' or 'bydate') to command setduperules specifies the file parameter to be compared.
# 2nd, 3rd and 4th argumnets("resume", "rename" , "overwrite", or "skip") specifies the transfer rule to be followed if the file to be transferred is
# less than the already existing file, identical to the already existing file and greater than the already existing file respectively.

# overwrite if older, skip if same date or newer.
setduperules bydate, overwrite, skip, skip;

# commands enablepasv and disablepasv speicifies server initiated (PORT) data connection and client initiated (PASV) data connection respectively for regular FTP connections without encryption.
# connection mode : passive
enablepasv;

# commands ftpconnect, ftpconnectssh, ftpconnectssl or ftpconnectsslc are used to connect to the server.
# 1st and 2nd argument to the command specifies the IP address and listening port number of the server.
# 3rd and 4th arguments specify the username and password respectively of the user account, it is required for account login.

# Regular FTP connection is established using ftpconnect command, default port is 21.
ftpconnect(~server_address, ~server_port, ~login_name, ~login_password);

# ftpsetpath command is used to set the local and remote path
ftpsetpath local, ~local_path;
ftpsetpath remote, ~remote_path;

# ftpgetlist command is used to get local or remote folder listing.
ftpgetlist local, @local_list;
ftpgetlist remote, @remote_list;
foreach $rem_item in @remote_list begin
  print "dosya ",$rem_item.name;
end
# foreach command is used to process the items in a variable that has a folder listing.
foreach $rem_item in @remote_list begin
  if $rem_item.isfolder eq false begin
    # ftpwildcardmatch command can be used to perform wildcard matching such as * and ?
    ftpwildcardmatch $rem_item.name, ~remote_fileformat, "i";
    if success eq ftpresult begin
      # ftpdownload command is used to download either a file or a folder.
      # 1st argument to command ftpdownload specifies the type of download file, it can be either  'file' or 'folder'.
      # 2nd argument specifies the name of the remote file to be downloaded.
      # 3rd argument is optional, it is used to specify the name in which the downloaded remote file must be saved in the local path.
      # if 3rd argument is omitted, the downloaded remote file will be saved with its remote file name in the local path.
      ftpdownload file, $rem_item.name;
      if ftpresult eq success begin
        # print a message to the user.
        print "command: ftpdownload; argument: file, ", $rem_item.name, "; status: pass;";
      end else begin
        # print a message to the user.
        print "command: ftpdownload; argument: ", $rem_item.name, "; status: fail;";
      end
    end
  end
end

LOG :::
---------------
Executing script C:\logs\Ulus178.fscr
Script Engine: Line 10: Executing setvar. Parameter(s):  ~server_address  "172.16.0.178"
Script Engine: Line 11: Executing setvar. Parameter(s):  ~server_port  21
Script Engine: Line 12: Executing setvar. Parameter(s):  ~login_name  "Admin"
Script Engine: Line 13: Executing setvar. Parameter(s):  ~login_password  "Admin123"
Script Engine: Line 14: Executing setvar. Parameter(s):  ~remote_path  "/swpkg_a/webct/data/"
Script Engine: Line 15: Executing setvar. Parameter(s):  ~local_path  "c:\logs"
Script Engine: Line 16: Executing setvar. Parameter(s):  ~remote_fileformat  "*.*"
Script Engine: Line 25: Executing setduperules. Parameter(s):  bydate  overwrite  skip  skip
Script Engine: Line 29: Executing enablepasv
Script Engine: Line 36: Executing ftpconnect. Parameter(s):  ~server_address  ~server_port  ~login_name  (not displayed)
220 Interpeak FTP server 1.1.2 ready.
USER Admin
331 Password required for user Admin
PASS Admin123
230 Login OK
PWD
257 "/" is current directory
PWD
257 "/" is current directory
Remote path: /
Local  path: C:\Program Files\SysaxAutomation\
Script Engine: Line 39: Executing ftpsetpath. Parameter(s):  local  ~local_path
Local  path: c:\logs
Script Engine: Line 40: Executing ftpsetpath. Parameter(s):  remote  ~remote_path
CWD /swpkg_a/webct/data
250 CWD changed
PWD
257 "/swpkg_a/webct/data/" is current directory
Remote path: /swpkg_a/webct/data/
Script Engine: Line 43: Executing ftpgetlist. Parameter(s):  local  @local_list
Successfully obtained local folder listing
Script Engine: Line 44: Executing ftpgetlist. Parameter(s):  remote  @remote_list
TYPE A
200 Type A selected
PASV
227 Entering passive mode (172,16,0,178,250,146)
LIST
125 Using existing data connection
226 Transfer complete
Script Engine: Script execution complete
Script completed with an exit code of 0
Posted:  16 Feb 2010 20:17
It looks like you are using regular FTP to connect to the remote server. Are you able to see any items in the folder when you connect to the server using the command line ftp.exe program?
 

Copyright © 2021 Codeorigin, LLC - All Rights Reserved.
XML RSS 2.0 XML Atom 1.0