Standard IO Redirection and Event Handler Processes - Command Execution

Command Execution

If an event handler executes a command, standard I/O redirection can be specified with the handler's USER_COMMAND option. The value of this option would be the same as it would be if you were issuing the command and redirecting I/O from the command prompt.

The following figure provides examples.


Example 1

Example 1 shows how to send the results of a dir*ectory listing on a Windows system to a file in the current directory named *dirout.txt.

Example 2

Example 2 can be run on a Windows or UNIX system. It demonstrates the execution of an application named someapp that receives its input from a file named appinput.dat, and is redirecting all messages destined for stdout and stderr to a file named applog.txt. The contents of applog.txt are overwritten each time that the command executes.

Example 3

Example 3 also can be run on a Windows or UNIX system. It executes an application named dailybkup, and appends all messages destined for stdout to backup.log and all messages destined for stderr to a file named backup_err.log.

Because the file name does not change with each invocation of the event handler, this method is best suited for event handler processes whose output does not need to be captured in unique files. If multiple event occurrences cause this event handler process to be executed at the same time, the output from each instance of the event handler process will be interleaved within the same file.


Windows

Special consideration should be given when executing several instances of an event handler process that redirects output to a single file. Sharing violations have been observed in this situation that prevent output from being properly captured. For these cases, it is recommended that a method be used that provides for assignment of a unique file name to each process instance.