The subtleties of writing DTrace scripts

(1) Assume you write your DTrace script on Windows and run it on Unix. Because Windows uses \r\n as EOL while Unix uses \n, if you execute it directly, following complain will occur:

: No such file or directory

The solution is to apply dos2unix to convert file format before playing it.

(2) The shebang line of script only accepts 1 argument, and -s option must be the last. For example:

#!/usr/sbin/dtrace -sq

Will generate following error:

dtrace: failed to open q: No such file or directory

While “#!/usr/sbin/dtrace -qs” will be OK. To make additional options take effect, please use #pragma directive:

#pragma D option ...

Reference:
Does DTrace script only support “#pragma D option ..”, not “-x option”?.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.