<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > FTP. - and more > Internet and Network Commands |
MiniRobotLanguage (MRL)
FTP.ftp download
FTP.ftp
Dowload Files via FTP to a local folder
Intention
This command can be used to download a File or multiple files via the FTP-Protocol to your computer. You can use Login and Password and you can use wildcards to define which files you want to download.
' The ftp-server
$$URL=ftp-server.de
' Your Login
$$LOG=your_login
' Your Password
$$PWD=the-password
' The folder on the ftp-derver
$$PAT=site-folder
' File-Mask. Define which file(s) you want to download
' using wildcards: ?/*
$$FIM=*.*
' The local path where you want these files
' to downloaded to
$$LOC=?path\test\
FTP.ftp|$$URL|$$LOG|$$PWD|$$PAT|$$FIM|$$LOC
ENR.
The command does also give you a return on how things worked out.
For this you can specify three additional variables. Like this:
FTP.ftp|$$URL|$$LOG|$$PWD|$$PAT|$$FIM|$$LOC|$$REA|$$REB|$$REC
PRT.----------------
PRT.REA=$$REA
PRT.----------------
PRT.REB=$$REB
PRT.----------------
PRT.REC=$$REC
PRT.----------------
MBX.!
ENR.
The result could look like in teh picture below.
P7/$$REA shows how many files have been successfully transferred.
P8/$$REB shows you a textual Message if there were fatal Errors.
P9/$$REC contains a detailed list with all FTP transfers that were successful or not.
P9 will also list folders and files that can not be transferred due to right or other
problems. Files that have been copied and counted will be in small letter and
prefixed with a "OK:". Files that could not be transferred will be prefixed with a "ER:".
Folders can not be transferred, yet they are listed if there are folders.
If you specify an invalid remote-folder or no remote folder (leave P4 empty), the root-folder that you have permission with you ftp-Login and Password, is used instead.
Therefore in most cases you may leave P4 empty.
Example:
If you have on your FTP-Server this folder:
wrcom/site
and your FTP-Login and Password is for "wrcom", then you will always get the files from "wrcom" if you specify an invalid folder. To get the file4s that are inside "wrcom/site" you do have to specify "site" as remote-folder. Do not specify "wrcom/site" as this may not work.
Here is an example with just one file downloaded.
Here is what you get if you specify an invalid FTP server or if your firewall blocks the connection. As you can see, Error-Numbers are negative, this way you can easily find out, if there was a problem, using:
IVV.$$REA<0
PRT. There was a Problem! ($$REB)
EIF.
It will look like this:
Syntax
FTP.ftp|P1|P2|P3|P4|P5|P6[|P7][|P8][|P9]
Parameter Explanation
P1 - URL of FTP-Server
P2 - Login for FTP-Server (Leave empty if none)
P3 - Password for FTP-Server (Leave empty if none)
P4 - remote-folder (Folder on the ftp-server), leave empty to use root-folder.
Please read comments about P4 in the text above!
P5 - file-name/file-mask specify which file(s) you want to download.
You can use wildcards * and "?".
P6 - Local path to save the transferred files to.
P7 - (optional) Returns an numeric code that shows success or failure
of the operation. If omitted the number will be placed on TOS.
This numeric number will be positive in case of success and negative in case
fatal of errors.
If P7 is positive, the number is the number of files that have been
transferred successfully.
if P7 is negative, read P8 for an explanation of the error that has happened.
P8 - (optional) Return the textual message that corresponds to the numerical
number in P7.
P9 - (optional) Return a $crlf$ separated list with all files/ folders
that have been processed. P9 contains a detailed list with all FTP
transfers that were successful or not.
P9 will also list folders and files that can not be transferred due to right or other
problems. Files that have been copied and counted will be in small letter and
prefixed with a "OK:". Files that could not be transferred will be prefixed with a "ER:".
Folders can not be transferred, yet they are listed if there are folders.
This is how the stack looks, if you do not specify P7, P8 and P9.
Example
'***********************************
' FTP.-DEMO
'***********************************
' The ftp-server
$$URL=ftp-server.de
' Your Login
$$LOG=your_login
' Your Password
$$PWD=the-password
' The folder on the ftp-derver
$$PAT=site-folder
' File-Mask. Define which file(s) you want to download
' using wildcards: ?/*
$$FIM=*.*
' The local path where you want these files
' to downloaded to
$$LOC=?path\test\
FTP.ftp|$$URL|$$LOG|$$PWD|$$PAT|$$FIM|$$LOC|$$REA|$$REB|$$REC
PRT.----------------
PRT.REA=$$REA
IVV.$$REA<0
PRT. There was a Problem! ($$REB)
EIF.
PRT.----------------
PRT.REB=$$REB
PRT.----------------
PRT.REC=$$REC
PRT.----------------
MBX.Ready
ENR.
Remarks
-
Limitations:
-
See also:
• FTP. - File Transfer Protokoll
• fto - file transfer protocol
•