perlquestion
adalby
I need to find the actual full path of an executing program. The program may be running multiple times concurrently and out of different locations. I need to match each executing instance with its location. Using shell scripts, I can get the pid by ps -eo|grep xxx, and then sudo readlink /proc/$PID/exe. However, I'd really like to code the monitoring in perl, since there are additional perly things I want to do with the info. Is it possible to run the perl script as normal user and only elevate permissions for the readlink() function call?
<code>
semi-functional shell script:
for PID in $(ps -eo pid,user,lstart,cmd|grep xxx|cut -d" " -f1)
do
sudo readlink /proc/$PID/exe >>output
done
</code>
Alternatively, is there a way to find the full path of an executing program?