system

This command is part of the TclX package.

system cmdstr1 ?cmdstr2 ...?

Concatenates cmdstr1, cmdstr2 etc. with space separators (see the concat command) into a single command and then evaluates the command using the standard system shell. On Unix systems, this is /bin/sh and on Windows it is command.com or cmd.exe (depending on version). The exit code of the command is returned.

This command differs from the exec command in that system doesn't return the executed command's standard output as the result string (instead, it returns a return code of the command that was executed), and system goes through the Unix shell to provide wildcard expansion, redirection, etc, as is normal from an sh command line.

One example is:

$ tclsh8.5
% package require Tclx
8.4
% system fgrep lvirden /etc/motd
1
% exec fgrep lvirden /etc/motd
child process exited abnormally
% set rc [system fgrep Sun /etc/motd]
Sun Microsystems Inc.   SunOS 5.8       Generic Patch   December 2002
% puts $rc
0
%