<< back to sysax.com Product page |
The ftprunprogram command runs a program on the local computer. The path to the program executable and the parameters to be passed to the program should be specified. The program can also be executed as a specific user if an optional username and password are provided. The command will fail to run the program if a username and password are specified but the user process running the ftp script does not have sufficient permissions to login as the specified user. It is therefore possible that the command successfully invokes the program when running under the scheduler service or as part of a server script (both of which run with systemwide permissions) but fails when run from the command line, logged in as a specific user.
A timeout value in seconds can be optionally specified to terminate the program if it has not completed in the specified time. If a timeout value is not specified or if a value of 0 is specified, the script will wait until the program completes execution. The ftpresult
predefined status flag is set to the predefined constant success
if the command completed successfully. An expected exit code value can also be optionally specified to compare against the actual program exit code. If the exit codes do not match, The ftpresult
predefined status flag will not be set to the predefined constant success
.
Exhibit 5.9. Sytax of command for executing local programs
ftprunprogram <program path string>, <parameter string> [, optional: <username>, <password>, <timeout value>, <expected error code>]; |
Exhibit 5.10. Example for using the command for executing local programs
ftprunprogram "c:\\Program Files\\notepad.exe", "C:\\myfile.txt"; #open a file in notepad ftprunprogram "c:\\Program Files\\myprog.exe", "", "administrator", "admin"; #run a program as the administrator ftprunprogram "c:\\Program Files\\myprog.exe", "", "", "", 10; #run a program but terminate it if it takes more than 10 seconds to run ftprunprogram "c:\\Program Files\\myprog.exe", "", "", "", 0, 1; #run a program to completion and verify that the exit code is 1 |