ls
command through a pipe to the wc
(word count) command: ls | wc -w
ps
(process) command to a SAS DATA step. The resulting
SAS data set contains data about every process currently running
SAS: filename ps_list pipe "ps -e|grep 'sas'"; data sasjobs; infile ps_list; length process $ 80; input process $ char80.; run; proc print data=sasjobs; run;The
ps -e
command produces
a listing of all active processes in the system, including the name
of the command that started the task. In BSD-based UNIX systems,
you use the ps -ax
command.
ps
to
the grep
command, which searches for every
occurrence of the string 'sas'
. The FILENAME
statement connects the output of the grep
command to the fileref ps_list
. The DATA
step then creates a data set named sasjobs
from the INFILE statement that points to the input source. The INPUT
statement reads the first 80 characters on each input line.
data sasjobs; infile stdin; length process $ 80; input process $ char80.; run; proc print data=sasjobs; run;To run the program, use pipes to send the output of
ps
to grep
and
from grep
into the SAS command: ps -e|grep 'sas'|sas ps.sas &The output will be stored in
ps.lst
, and the log will be
stored in ps.log
, as described in The Default Routings for the SAS Log and Procedure Output in UNIX Environments.filename letterq pipe 'remsh alpha lp -dbldga3';Any data sent to the
letterq
fileref is
passed to the UNIX command, which starts a remote shell on the computer
named Alpha. Note that the form of the command that starts a remote
shell varies among the various UNIX operating systems. The shell then
prints the letterq
output on the printer
identified by the destination BLDGA3. Any messages that are produced
by the lp
command are sent to the SAS log.