EXEC        Execute an external program

Top  Previous  Next

Syntax:

EXEC

[ exec name ]  [ /options ]

Arguments:

[ exec name ]

Variable or string defining a file or path name of an executable program, including any program command line arguments; if no path is defined Robo-FTPs working folder is used; MS-DOS internal commands such as dir are not supported.

Options:

/nowait

Continue script execution after starting external program.

 

/passargs

Any subsequent variables or strings following this option are passed as arguments to the program to be run.

 

/passerror

Pass the result code from the last script command as an argument to the executed program.

 

/timeout=x

Number of seconds to wait for the external program to complete. When no timeout is specified Robo-FTP will wait indefinitely.

 

 

This script command executes a specified external program.

 

The /nowait option determines if the script file execution is suspended until the external program is complete or continues to run. If this option is omitted, script file execution resumes when the program terminates.

 

The /passargs option allows you to pass any number of variable or string values from the script file to the program to be executed as if they are specified on the Shortcut Target command line. Any variables or string values that follow the /passargs delimiter within the EXEC command line are passed in this way. Consider the following example.

 

SET program_name = "myprog.exe -abc"

SET flag = "-xyz"

EXEC program_name /passargs "-p2" flag

 

The effective command line to the program myprog.exe would be:

 

myprog.exe -abc -p2 -xyz

 

The exit value of the executed program is obtained by Robo-FTP when it terminates and it becomes the EXEC commands result code. This result code may be useful in subsequent conditional branching tests in the script file.

 

If you need to use a file or folder path containing a space character, you can use single quote characters as a string delimiter for the Robo-FTP command parser and the double-quote character as the delimiter for the command passed to Windows, like this:

 

EXEC 'notepad.exe "c:\Program Files (x86)\Robo-FTP 3.8\Readme.txt"'

 

The /passerror option permits an external program to deal specifically with a particular error condition that may be beyond the scope of a Robo-FTP script file. The external program receives the command line parameter in this format: /flerr=XXXX

 

The /timeout option allows you to specify the maximum amount of time to wait for the program to complete. This option is useful for protecting your command script from an unreliable external program. If you do not specify a timeout and the external program hangs without exiting then Robo-FTP will wait indefinitely. If the launched program does not complete execution prior to the expiration of the timeout period Robo-FTP will continue processing the command script with the next line after the EXEC command and also attempt to terminate the launched program.

 

Important

If you use the EXEC command to launch additional instances of Robo-FTP we strongly recommend adding Robo-FTP to the Path environment variable. This makes it possible to pass  only "Robo-FTP.exe" in the [ exec name ] argument instead of passing the full installed path which in turn simplifies both the process of migrating to future versions of Robo-FTP and  of rolling-back if necessary.

 

 

Related command(s): CALL, CHAIN, DOSCMD

See also: Script File Result Codes, Simultaneous Execution