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 FileLink’s 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.

 

 

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 specified on the Shortcut Target command line. Any variables or string values that follows 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 FileLink 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.

 

Consider the following example where you have a program called password .exe which checks for a valid password string. The program returns 0 if the password is valid and 1 otherwise. The following script file would verify a password and then send a file to the caller only if an acceptable password was received.

 

ANSWER /timeout=0

;; wait to receive password text

LINEIN rcvd_password

;; check for valid password in variable 'rcvd_password'

EXEC "password.exe" /passargs rcvd_password

;; don't send if invalid password

IFERROR goto disconnect

;; send the file

SENDFILE file1

:disconnect

DISCONNECT

EXIT

 

The /passerror switch causes the result code from the last script command to be passed an argument to the executed process. The form of the argument is /flerr=xx. Consider the following example where the previous script command terminated with a result code of 1013.

 

       SET program_name = "myprog.exe -abc"

       EXEC "program_name" /passerror

 

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

 

       myprog.exe -abc /flerr=1013

 

This option permits an external program to deal specifically with a particular error condition that may beyond the scope of a FileLink script file.

 

Related Command(s): CALL, CHAIN , DOSCMD, WORKINGDIR

See also: Script File Result Codes