Ftp Commands

This task allows you to connect to a ftp server and issue commands.  There are two types of commands supported:
1) The standard ftp commands as defined in RFC 959.  Please see list of ftp commands.  Only the most useful commands are listed here.  Please search the internet for RFC 959 if you need more information on all the standard Ftp commands.
2) Custom functions provided by the Ftp Command task.  Please see list of custom functions.

Please note that the ftp commands that you normally use in the ftp commandline tools in MSDOS, MacOSX or Unix etc.. are not necessarily supported.  For example, the LS, CD, Get or Put commands in many commandline ftp tools are not valid RFC 959 ftp commands.  Get and Put are commands created by many commandline ftp tools to implement the RETR and STOR commands of RFC 959.  To put or get files, you can use the custom functions $$GET& $$PUT etc.. which are provided by this task.

This task is multithreaded.  So you can run multiple Ftp Command tasks simultaneously.  Most other Automize tasks are synchronized, i.e. a copy task will wait in line for another copy task to finish.  The synchronized tasks prevent overlapping schedules.  The Ftp Command task is multithreaded because invalid user commands may cause a task to stall indefinitely.  If this task was synchronized, this situation would cause other Ftp Command tasks or subsequent schedules to wait indefinitely too.

This task also outputs dynamic variables for each response provided by the Ftp server.  The variables are of the form TaskTitle::ResponseX where X is the response from the srever for each of your Ftp commands.  You can use these response variables in a Variable Monitor task to do conditional processing.

Host
Enter the host name or IP address of the Ftp server.  If you have to connect through a Ftp proxy server or firewall, enter the host name or IP address of the firewall or proxy server.

Port
Enter the desired port.  Default Ftp port = 21

Password
In the password field, enter your password required to connect.  Then in the command list, use the following syntax to send the hidden password:  $$LOGIN::username::$PASSWORD$ ,  or if you need to manually login, use: PASS $PASSWORD$.  The string $PASSWORD$ will be replaced by the value in the password field.  If you have no reason to hide your password, you do not need to fill in the password field.

Commands
Enter your ftp commands, 1 per line.  The custom commands are case sensitive.  First line should normally be the USER command, and second line should normally be the PASS command.  This field also supports dynamic variables.  Using dynamic variables, you can enter a command which will be dynamically resolved at runtime.  example: cd /users/$%USERNAME%$

Example1
USER tom                                        sends username
PASS $PASSWORD$                    sends password
ACCT  production                           sends account information
PWD                                               prints current remote ftp directory
CWD /users/tom                              sets /users/tom as the current ftp directory
$$LCD::c:\test                                  sets c:\test as the current local directory
$$MPUT::test                                  puts all files from c:\test, which include 'test' in their name, to /users/tom
$$MGET::                                       gets all files from /users/tom to c:\test

Example2
$$LOGIN::user::$PASSWORD$     logon information
PWD                                               prints current remote ftp directory
CWD /users/tom                              sets /users/tom as the current ftp directory
$$LCD::c:\test                                  sets c:\test as the current local directory
$$PASV                                          sets the passive mode of transfer
$$GET::test.txt                                 gets test.txt from /users/tom to c:\test
$$PUT::test.txt                                 puts test.txt from c:\test to /users/tom
 
 
List of custom commands
$$LOGIN Description: Simple logon using username and password information
Syntax: $$LOGIN::username::password
Examples: $$LOGIN::jim::jim04      or  $$LOGIN::jim::$PASSWORD$
Comments:  To hide password, use $PASSWORD$ and enter password in password field
For more complicated logons or to connect through firewalls, you may need to use as required:
USER, PASS, ACCT, SITE, OPEN etc..
$$LCD Description: Sets the current local folder
Syntax: $$LCD::path_to_local_folder
Example: $$LCD::c:\data\test
Comments: Very important.  Should always be set before transferring files
Comments:  Internal module use only.  Ftp server has no idea about current local folder
Comments:  Used internally by $$PUT, $$GET, $$MPUT, $$MGET, $$MDEL functions
$$PASV Description: Sets the passive mode of transfer. 
Syntax: $$PASV
$$PUT Description: Puts a single file from current local folder to current remote ftp folder
Syntax: $$PUT::filename
Example: $$PUT::test.txt
Comments: Only single file is put, file should exist in current local folder
$$GET Description: Gets a single file from current remote ftp folder to current local folder
Syntax: $$GET::filename
Example: $$GET::test.txt
Comments: Only single file is got, file should exist in current remote ftp folder
$$PPUT Description: Puts a single file from local path to ftp path
Syntax: $$PPUT::path_to_local_file::path_to_remote_file
Example: $$PPUT::c:\data\test.txt::/users/tom/test5.txt
Comments: Only single file is put, file path should exist in the local system
$$PGET Description: Gets a single file from ftp path to local path
Syntax: $$PGET::path_to_remote_file::path_to_local_file
Example: $$PGET::/users/tom/test5.txt::c:\data\test.txt
Comments: Only single file is got, file path should exist in the remote system
$$MPUT Description: Puts multiple files from current local folder to current ftp folder
Syntax: $$MPUT::filename_filter
Example: $$MPUT::                      (will put all files from current local folder)
Example: $$MPUT::test                 (will put all files which include test in their name)
Example: $$MPUT::.txt^.htm         (will put all files which have .txt or .htm extensions)
Comments: Enter the filename_filter using the following wildcard rules
$$MGET Description: Gets multiple files from current ftp folder to current local folder
Syntax: $$MGET::filename_filter
Example: $$MGET::*                    (will get all files from current ftp folder)
Example: $$MGET::test                 (will put all files which include test in their name)
Example: $$MGET::.txt^.htm         (will put all files which have .txt or .htm extensions)
Comments: Enter the filename_filter using the following wildcard rules
Comments: Automatically detects directory listing style and get directory information
$$MSGET Description: Gets multiple files from current ftp folder to current local folder
Syntax: $$MSGET::*                    (will get all files from current ftp folder)
Example: $$MSGET::test                 (will put all files which include test in their name)
Example: $$MSGET::.txt^.htm         (will put all files which have .txt or .htm extensions)
Comments: Enter the filename_filter using the following wildcard rules
Comments: Only obtains names of objects in current ftp directory
This function does not try to detect if object is File or Directory
It will also try to GET directories if they satisfy the filename filter.
This results in the following error being output for every Directory in current ftp folder:
550 dir_name: [Error information varies by ftp server].  This is expected behaviour.
$$MDEL Description: Deletes multiple files from current ftp folder
Syntax: $$MDEL::filename_filter
Example: $$MDEL::                      (will delete all files from current local folder)
Example: $$MDEL::test                 (will delete all files which include test in their name)
Example: $$MDEL::.txt^.htm         (will delete all files which have .txt or .htm extensions)
Comments: Enter the filename_filter using the following wildcard rules

 
List of useful ftp commands - RFC 959
HELP Description: Returns list of commands or details for a single command
Syntax: HELP [command]
Example: HELP                   returns a list of commands supported by the ftp server
Example: HELP  USER       returns details on the USER command
USER Description: Sends the username to begin the login process
Syntax: USER userID
Example: USER tom
PASS Description: After sending the USER command,send this command to complete login
Syntax: PASS user_password
Example: PASS ergts56r
PASV Description: Sets the passive mode of transfer. 
Syntax: PASV
TYPE Description: Specifies ascii or binary mode of data transfer
Syntax: TYPE mode
Example: TYPE I     or    TYPE A
Comments: A - ASCII text, E - EBCDIC text, I - image (binary data)
PORT Description: Specifies host & port to which the ftp server should connect for next data transfer
Syntax: PORT h1,h2,h3,h4,p1,p2
Example: PORT 192,168,0,121,15,196
Comments: ip address = h1.h2.h3.h4,  port = p1*256 + p2
ACCT Description:Sends the account required for login
Syntax: ACCT account_name
Comments: normally sent after the PASS command.  Uncommon command
CWD Description: Sets the current ftp directory on remote ftp server
Syntax: CWD remote_ftp_path
Example: CWD /users/tom/data
CDUP Description: Sets the parent of the current ftp folder to be the current ftp folder
Syntax: CDUP
DELE Description: Deletes a single file from the current ftp folder
Syntax: DELE filename
Example: DELE test.txt
RNFR Description: Used to rename a file.  Specifies the file to be renamed
Syntax: RNFR original_name
Example: RNFR test.txt
Comments: Should be followed by RNTO command
RNTO Description: Used to rename a file.  Specifies the new name for the file
Syntax: RNTO new_name
Example: RNTO new.txt
Comments: Should be preceded by RNFR command
SITE Description: Used to issue a site specific command
Syntax: SITE command
Example: Use 'HELP SITE' to see list and syntax of supported commands
Comments: May not be supported by many Ftp servers
RETR Description: Transfers file from remote host
Syntax: RETR filename
Example: RETR test.txt
Comments: Should be preceeded by the PORT or PASV commands
STOR Description: Transfers file to the remote host
Syntax: STOR filename
Example: STOR test.txt
Comments: Should be preceeded by the PORT or PASV commands