tags:

views:

118

answers:

1

How can I redirect only Dtrace's output when running a script with the -C flag?

like in this case:

dscript.d -s myscript.d -c date

Note: I found the answer to my question before posting it, but I'm putting it here so it's part of SO.

A: 

One solution with pipes is:

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 the more simpler method is to do:

dtrace -o log.txt -s dscript.d -c date
Robert Gould