Chapter Contents |
Previous |
Next |
SYSTASK |
Alias: | LISTTASK is an alias for SYSTASK LIST |
Valid: | anywhere |
UNIX specifics: | all |
Syntax | |
Details | |
See Also |
Syntax |
SYSTASK COMMAND "host-command" <WAIT|NOWAIT> <TASKNAME=taskname> <MNAME=name-var> <STATUS=stat-var> <SHELL<="shell-command">> <CLEANUP>; |
SYSTASK LIST <_ALL_ | taskname> <STATE> <STATVAR>; |
SYSTASK KILL taskname <taskname...>; |
SYSTASK COMMAND "xdialog -m ""There was an error."" -t ""Error"" -o";
Note: The host-command that you
specify cannot require input from the keyboard.
Task names cannot be reused, even if the task has completed, unless you either issue the WAITFOR statement for the task or you specify the CLEANUP option.
Note: The SHELL option assumes that the shell command that you specify
uses the
-i
option to pass
statements. Usually, your shell command will be
sh
,
csh
,
ksh
, or
bash
.
Details |
SYSTASK allows you to execute host-specific commands from within your SAS session or application. Unlike the X statement, SYSTASK runs these commands as asynchronous tasks, which means that these tasks execute independently of all other tasks that are currently running. Asynchronous tasks run in the background, so you can perform additional tasks while the asynchronous task is still running.
For example, to start a new shell and execute the UNIX
cp
command in that shell, you might use this
statement:
systask command "cp /tmp/sas* ~/archive/" taskname="copyjob1" status=copysts1 shell;The return code from the
cp
command is saved in the macro
variable COPYSTS1.
The output from the command is displayed in the SAS log.
Note: Program steps that follow the SYSTASK statements in SAS applications
usually depend on the successful execution of the SYSTASK statements. Therefore,
syntax errors in some SYSTASK statements will cause your SAS application to
abort.
There are two types of tasks that can be run with SYSTASK:
The SYSRC macro variable contains the return code for the SYSTASK statement. The status variable that you specify with the STATUS option contains the return code of the process started with SYSTASK COMMAND. To ensure that a task executes successfully, you should monitor both the status of the SYSTASK statement and the status of the process that is started by the SYSTASK statement.
If a SYSTASK statement cannot execute successfully, the SYSRC macro variable will contain a non-zero value. For example, there may be insufficient resources to complete a task or the SYSTASK statement may contain syntax errors. With the SYSTASK KILL statement, if one or more of the processes cannot be killed, SYSRC is set to a non-zero value.
When a task is started, its status variable is set to NULL. You can
use the status variables for each task to determine which tasks
failed to complete. Any task whose status variable is NULL did not complete
execution. If a task terminates abnormally, then its status variable will
be set to -1
. See WAITFOR for more information about the status variables.
Unlike the X statement, you cannot use the SYSTASK statement to start a new interactive session.
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.