[dtrace-discuss] "dtrace -c" : how to redirect output

Michael Shapiro mws at zion.eng.sun.com
Wed Jan 31 14:27:23 PST 2007


> Hi,
> 
> Is it possible to redirect the output of the command specified as -c 
> argument?
> I.e. to do something like:
> # dscript.d -c "date 1>out 2>err"
> 
> thanks in advance,
> -katya

We don't support shell expansions in the -c argument.  If you want to do
the above, one easy way from ksh or bash is this:

dtrace -o /dev/fd/3 -s dscript.d -c date 3>&1 1>out 2>err 

which says:

dtrace's stdout goes to fd 3, which is dup'd from the current stdout
dtrace's stderr goes to 'err'

date's stdout is modified to 'out'
date's stderr is modified to 'err'

Or you can use -o to specify a particular output file.

-Mike

-- 
Mike Shapiro, Solaris Kernel Development. blogs.sun.com/mws/


More information about the dtrace-discuss mailing list