Alan Hargreaves' Blog

The ramblings of a former Australian SaND TSC* Principal Field Technologist

Finding undocumented command options

I had a colleague this morning asking about undocumented (ie not listed in usage or man pages) options in a command. The actual command doesn’t really matter, but I was feeling a little lazy and couldn’t bothered looking up the source code to the command (which actually wasn’t in ON). Almost immediately I thought of DTrace.

Let’s have a look at ls as an example. I’ll give it a dummy directory as I really don’t care about the output.

$ dtrace -q -n 'pid$target::getopt:entry {trace(copyinstr(arg2));}' -c 'ls /nosuchfile'
/nosuchfile: No such file or directory

As you can see, the second line of output is printing out the third argument (arg2) to getopt(3c), which will list every option that getopt(3c) will recognise for the command.

Of course I could have prettied it up, but it’s a one liner, I know what the output means.

The point being, that DTrace is just another sysadmin tool to be used in day to day operations.

Technorati Tags:

Yes I know I have been lax in my blogging, I’m going to start doing something about that, starting with this one 🙂


Written by Alan

August 7, 2007 at 6:47 pm

Posted in OpenSolaris

%d bloggers like this: