For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > May 2005 > howto list running processes with Perl?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author howto list running processes with Perl?
clint

2005-04-19, 3:56 pm

please help.
i need to list running processes with Perl, any suggestions?
many thanx
clint
clint

2005-04-19, 3:56 pm

On Tue, 19 Apr 2005 16:17:52 +0000, clint wrote:

> please help.
> i need to list running processes with Perl, any suggestions?
> many thanx
> clint


sorry i mean howto count them!
thanx
clint

Rene Schickbauer

2005-04-20, 3:56 am

clint wrote:

> On Tue, 19 Apr 2005 16:17:52 +0000, clint wrote:
>
>
> sorry i mean howto count them!
> thanx
> clint


A rude approach would be to use backticks:

my @proc = `ps -ax`;
my $cnt = $#proc;
print "Running processes: $cnt\n";

But while where already spawning a process, why not spawn 2 and save a line
of code:

my $cnt = `ps -ax | wc -l` + 0;
print "Running processes: $cnt\n";

LLAP & LG
Rene
George Bouras

2005-04-20, 3:56 pm

For windows you can use the Win32_Process of wmi , or for faster execution
use the Win::API module to call the psapi.dll


Eric Teuber

2005-04-21, 8:55 pm

Rene Schickbauer wrote:
> clint wrote:
>
>
>
>
> A rude approach would be to use backticks:
>
> my @proc = `ps -ax`;
> my $cnt = $#proc;
> print "Running processes: $cnt\n";
>
> But while where already spawning a process, why not spawn 2 and save a line
> of code:
>
> my $cnt = `ps -ax | wc -l` + 0;
> print "Running processes: $cnt\n";
>
> LLAP & LG
> Rene


why not just

print `ps -ef | wc -l`;

Eric
Tim X

2005-05-05, 8:55 am

clint <clint@freemail.hu> writes:

> please help.
> i need to list running processes with Perl, any suggestions?
> many thanx
> clint


On what platform - windows, mac, linux?

Tim
--
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you
really need to send mail, you should be able to work it out!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com