• shellExec ?-outProc proc? ?-errProc proc? ?-stopProc proc? ?-timeout num? ?-success val? ?-preserve? ?--? scriptPath ?argList?
Execute a shell command synchronously. The scriptPath argument is
the full path of the shell script to execute. This path may contain shell
symbols like ..
or ~
. The argList argument is a Tcl
list containing the arguments to pass to the shell command.
The -outProc and -errProc options specify Tcl callbacks which will be invoked
each time new data is received on the stdout or stderr
channels of the shell command respectively. If only -outProc is
specified, then the -errProc option is automatically set to the
same value. These callbacks are Tcl procs accepting a single argument which
represents the received data. The callbacks are optional: if they are not
specified, the shellExec command returns the entire output of the
executed shell command upon completion.
The -timeout specifies a timeout in
seconds. If the elapsed time since the shell command was launched exceeds
the timeout, the shell command will receive an interrupt signal. By
default, there is no timeout.
The -stopProc option specifies a Tcl
proc which is invoked periodically to ask whether the execution should be
interrupted. This proc takes no argument and should return 1 to interrupt
the execution, or 0 otherwise.
By default, the command succeeds if the shell command terminates
with a 0 status (which is usual practice with shell commands). The -success option can be used to specify another
value for successful termination. If the termination status differs from
the expected success value, the shellExec command raises an error.
The '--' switch indicates the end
of the shellExec command's options.
The -preserve option is very
technical. Normally, the system applies a
Unicode formD decomposition to
all the arguments contained in argList. For some command line
tools, this can be undesirable. The -preserve option tells the
command to keep the arguments verbatim, that is, to pass them as they are,
without decomposing.