Jeff Abrahamson on 5 Jan 2004 12:31:03 -0000 |
On Mon, Jan 05, 2004 at 01:38:38AM -0500, Michael C. Toren wrote: > [32 lines, 192 words, 1392 characters] Top characters: etinosal > > On Sun, Jan 04, 2004 at 11:11:19PM -0500, Stephen Gran wrote: > > What I'm looking for is something like $PPID, or maybe $$, but that > > gives me a little more information to work with, > > To extract argv[0] of the parent, perhaps you could use: > > awk '{print}' /proc/$PPID/cmdline > > Unfortunately, the above command is somewhat deceptive, at least for > mawk version 1.3.3-8, which is the awk implementation that happens to be > installed on my local system. Based on the output of the following test, > mawk seems to use nul-terminated strings internally, probably the result > of using stdio: > > [mct@ellesmere ~]$ echo -e "foo\0bar"| awk '{print}' > foo > > The net result is that it's easy to extract the first nul-terminated > string of /proc/$PPID/cmdline using awk, but not the second. I would > normally recommend using perl in a situation like this one, however I > believe the use of perl in Debian init.d scripts is frowned upon? | tr '\0' ' ' alternatively awk -F'\0' '{print $1}' /proc/$PPID/cmdline -- Jeff Jeff Abrahamson <http://www.purple.com/jeff/> GPG fingerprint: 1A1A BA95 D082 A558 A276 63C6 16BF 8C4C 0D1D AE4B Attachment:
pgpQ9NGztExQG.pgp
|
|