Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I capture the complete commandline in Perl?

Suppose the call was

/usr/local/bin/perl verify.pl 1 3 de# > result.log

Inside verify.pl I want to capture the whole call above and append it to a log file for tracking purposes.

How can I capture the whole call as it is?

like image 567
Lazer Avatar asked May 27 '11 19:05

Lazer


1 Answers

There is way (at least on unix-systems) to get whole command line:

my $cmdline = `ps -o args -C perl | grep verify.pl`;
print $cmdline, "\n";

e: Cleaner way using PID (courtesy of Nathan Fellman):

print qx/ps -o args $$/;
like image 179
w.k Avatar answered Sep 22 '22 05:09

w.k