Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

Syntax:

GETPARAM(param_number)

  • param_number: position of the parameter in the command line sequence.

Remarks:

  • This command is used to pass your own parameters to the script file. For example, a user name, a password, a date, etc. See the examples below. The first parameter is reserved to ScriptFTP as it is used to pass the script file name or path. All subsequent parameters are for your own use.
  • If you use parameters that contain spaces you have enclose them in double quotes. The resaon is shown in the following example:

    C:…\…\> ScriptFTP.exe script_file.ftp parameter3 parameter4 parameter five

    GETPARAM(5) will return parameter instead of parameter five and GETPARAM(6) will return five. Using double quotes solves the problem:

    C:…\…\> ScriptFTP.exe script_file.ftp parameter3 parameter4 “parameter five”

    Now GETPARAM(5) will return parameter five.

  • If you are using the script to EXE conversion service note that the generated EXE completely ignores the first parameter (the one with the script file name or path) and you can also use this parameter:

    C:…\…\> download.exe myuser 364352f /sourcefolder

Return Value:

The parameter requested. If the parameter has not been supplied on the command line GETPARAM will return nothing.

See Also:

ScriptFTP in the command line

Command History:

This command was added in ScriptFTP 2.1 build March 14th 2006

Examples:

$param1 = GETPARAM(1)
$param2 = GETPARAM(2)
$param3 = GETPARAM(3)
$param4 = GETPARAM(4)
$param5 = GETPARAM(5)
 
PRINT($param1)
PRINT($param2)
PRINT($param3)
PRINT($param4)
PRINT($param5)
 
# Calling ScriptFTP with the following line:
# scriptftp_console.exe this_script.ftp "my own param 1" other_param2 param3
#
# will produce the output:
# C:\Program Files\ScriptFTP\ScriptFTP_console.exe
# this_script.ftp
# my own param 1
# other_param2
# param3
# This script is used to upload a specified file
# to the FTP server. Use it this way:
# ScriptFTP.exe example2.ftp the_file_to_upload
 
$param3 = GETPARAM(3)
 
PRINT("Uploading file ".$param3)
 
OPENHOST("127.0.0.1","carl","123456")
 
PUTFILE($param3)
 
CLOSEHOST

The following screen shot shows the second example using the command prompt version of ScriptFTP:

getparam_example2