backIndex

Xelagot action script

Events: FTPComplete

Requires xelagot 3.607 or higher.

Refer to Events for general information about events.

See also File Transfer Protocol: FTP.

Installer:

OnFTPCompleteEvent <eventlabel>
Event type: 10350
is triggered when a FTP transaction has ended.

Prepare the parameters for connection:

FTPClear Clears all parameters, resetting them to default values.
FTPClearCMD Clears only the list of commands for the file transfer transactions (FTPPut.., FTPGet.., FTPChangeDir). These are filenames and directory specification of files on the local and remote computer.
FTPHost $h Sets the host, either as a dotted IP or as a machine name (e.g. ftp.xxx.com). Default is empty, must be set.
FTPPort %p
FTPPort $p
Sets the port. The default is port 21. To reset to default, set %p = 0 (or %p = 21), or $p = "". You may also specify $p = "ftp". It is usually not necessary to set this parameter, as FTP servers are required to listen to their default port.
FTPUser $u Sets the user name to log into the FTP server. Default is empty, must be set.
FTPPassword $w Sets the password for this user. Default is empty, usually required.
FTPRemoteDir $d Specifies the remote directory (if any) to change to when logged into the FTP server. Use an empty string if it is not needed (default). Note: you can also change directories (PWD) between file uploads and downloads with the statement FTPChangeDir $d, see below.
FTPTimeout %s Sets, in seconds, the timeout value. Default is 60 seconds.
FTPPassive ON|OFF Sets passive connection mode ON or OFF. Default is OFF.

Add the commands for the specification of the files to be transfered. These commands are added to a list of transaction commands, this list can be cleared beforehand with FTPClearCMD (also with FTPClear), see above.

FTPPutBIN $LocalFile $RemoteFile Upload $LocalFile to server with name $RemoteFile in Binary mode.
$LocalFile is a file on the bot's computer. The filename convention is explained in the section Filenames.
$RemoteFile must have the name of the file as it will be received by the FTP server. It may be left empty if the filename does not change. You can also specify $RemoteFile = "*" to change the filename to lower case.
FTPPutASC $LocalFile $RemoteFile Upload $LocalFile to server with name $RemoteFile in ASCII mode.
$LocalFile is a file on the bot's computer. The filename convention is explained in the section Filenames.
$RemoteFile must have the name of the file as it will be received by the FTP server. It may be left empty if the filename does not change. You can also specify $RemoteFile = "*" to change the filename to lower case.
FTPGetBIN $LocalFile $RemoteFile Download $RemoteFile in Binary mode to the bot's computer and save it as $LocalFile.
$LocalFile is the destination file on the bot's computer. It may be left empty if the file is to be stored under the same name as $RemoteFile in the current script's folder. The filename convention is explained in the section Filenames. If the destination path and folder does not exist, it will be created to accommodate the file.
$RemoteFile must be specified exactly as it is stored on the remote computer (no path). If the remote computer runs on Windows, the name is not case sensitive, but on Linux it is.
FTPGetASC $LocalFile $RemoteFile Download $RemoteFile in ASCII mode to the bot's computer and save it as $LocalFile.
$LocalFile is the destination file on the bot's computer. It may be left empty if the file is to be stored under the same name as $RemoteFile in the current script's folder. The filename convention is explained in the section Filenames. If the destination path and folder does not exist, it will be created to accommodate the file.
$RemoteFile must be specified exactly as it is stored on the remote computer (no path). If the remote computer runs on Windows, the name is not case sensitive, but on Linux it is.
FTPChangeDir $d Use this statement to change the active directory on the remote computer between file transfers. It is only necessary to do so if you have to change directory for some files during the FTP session.
Note: the statement FTPRemoteDir $d explained above does the same on logging in, so use it if all files are in the same remote directory.

Finally, install the FTPComplete even handler if it is not already installed (e.g. OnFTPCompleteEvent FTPComplete), and queue the request in the FTP client:

FTPConnect %ID Queues the FTP request, retrieving a unique ID for the transaction. When the transaction is complete (successfully or not), triggers FTPComplete event.

Specific FTPComplete event statements (must be inside the event handler):

GetEventType %a stores the event type code in variable %a
GetEventResult %r stores the event result code in variable %r. 0 means success, other than 0 signifies there has been an error and the transaction failed (either partially or completely). To know the reason of a failure, use GetFTPError $e.
GetFTPID %ID Retrieves the ID of this transaction. Compare it to the ID you got with FTPConnect %id
GetFTPError $e If an error occured, the reason is stored in $e. To test for errors or success, see GetEventResult.
GetFTPUploaded %u Gets the number of successfully uploaded files.
GetFTPDownloaded %d Gets the number of successfully downloaded files.



backIndex