APM: Question: How to access command line before its parsed into @ARGV

Bill Raty bill_raty at yahoo.com
Thu Aug 25 15:23:59 PDT 2005


In Linux one can access the pre-parsed command line given to
exec, using CPAN module Proc::ProcessTable .   It seems to
reflect the assertions that quotes are removed by the shell
before being given to exec.

=for example

use strict;
use warnings;
use Proc::ProcessTable;

my $proc_table = Proc::ProcessTable->new();
my ($process) = grep $_->{pid} == $$, @{ $proc_table->table()
my $cmndline = $process->{cmndline};
print "Command line for pid=$$: ($cmndline)\n";


The underlying problem is I need to gather forensics on an
executable running on AIX that hangs intermittently.  The idea
was to put a command proxy in its place (perl) that captures
invocation arguments, STDIN, invokes the miscreant, and logs
its STDOUT, STDERR and other vitals for later analysis. 
Hopefully I'll be able to gather information for logging a
support ticket with the producer of the executable.

Presumably the quotes I supply to this program don't reach it,
and I can apply the cmndline from above to an 'exec', 'open',
or 'open3'.

Reintarnation: Coming back to life as a hillbilly

More information about the Austin mailing list