Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop thru processes

Status
Not open for further replies.

CJason

Programmer
Oct 13, 2004
223
US
Two part question...I guess...

Is there a way to loop through the current running processes...looking for a process by name?

In that same vain, can I kick off a process from perl and give it a specific name?
 
What OS are you on?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Sorry, possibly on either Linux, UNIX or Windows. I was hoping there was a portable way of doing it from within Perl. If not, could you provide any OS specific examples?
 
Well on windows the perl processes all get started as perl.exe (with activestate anyway). On Linux/Unix they start as the program name /path/to/program.pl.

You can do a @proc = `ps -ef`; to get all the processes on a linux/unix box. You can then grep for the program to find it there.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Check out:
I've used a portion of the downloadable program quite successfully on the Win OS to look for rogue programs running on PCs. If you are in the market for it, build yourself a database of:
$prog_list{'good'}{$prog_name} = "some comment";
$prog_list{'bad'}{xx} = "some comment";
$prog_list{'dont_know'}{xx} = "some comment";
put this and a copy of perl.exe onto a pen/thumb/flash/other drive and you more or less have the beginning of a traveling road show. (Everyone out there raise your hand/keyboard if you've ever heard the following "Hey - you work with computers? Can you stop by the house and ....")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top