Name

bgexec

bgexec varName [options...] command [arg arg...]

Run an external program, like the Tcl exec command, but allow Tk to process events while the program is running.

Parameter varName is a global variable that will be set to the program’s exit status when the command is completed. Setting the variable will cause the pr ogram to be terminated with a signal.

Parameters command and args specify an external command with optional arguments in the same form as accepted by the Tcl exec command.

Normally, bgexec returns the results of the program. However, if the last argument is the ampersand (&), bgexec immediately returns a list of the spawned pr ocess IDs. The variable varName can be used with the tkwait command to wait for the program to finish.

Options

-error varName

Cause varName to be set to the contents of standard error when the command has completed.

-update varName

Cause varName to be set whenever data is written to standard output by the command.

-keepnewline boolean

Enable or disable truncation of newline from last line of output.

-killsignal signal

Specify (by name or number) the signal to be sent to the command when terminating. The default signal is SIGKILL.

-lasterror varName

Same as the -error option, except varName is updated as soon as new data is available.

-lastoutput varName

Same as the -output option, except varName is updated as soon as new data is available.

-onerror cmdPrefix

When new data from standard error is available, evaluate the command cmdPrefix with the new data ...

Get Tcl/Tk in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.