CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
[Advanced]Need a program that moniters .exe

 



praveenbond3
New User

Mar 21, 2009, 12:38 AM

Post #1 of 5 (3114 views)
[Advanced]Need a program that moniters .exe Can't Post

Hi,

I do not have much exp with perl programing..kindly somebody help me

My question :-

I need a program that moniters the exe(Windows taklist)..

I have two drivers in my PC and I am executing two perl progrmes (PrgrmA,PrgmB)from the command prompt of each drive..at the same time..

These two perl(PrgrmA,PrgmB) programes use same exes.. but there are 2 exes(Driver.exe,set.exe) which can be used by only one program (PrgrmA)at time..PrgmB has to wait untill exes (Driver.exe,set.exe) are set free..and then prgmB should start using Driver.exe,set.exe

and visa -versa.

I need a routine which moniters the existance of exes and executes the task required.

kindly some one help me..I do not have any code for the same...Waiting for positive reply from someone


(This post was edited by praveenbond3 on Mar 21, 2009, 8:24 AM)


Tumata
User


Mar 25, 2009, 6:43 AM

Post #2 of 5 (3059 views)
Re: [praveenbond3] [Advanced]Need a program that moniters .exe [In reply to] Can't Post

Hmm... It is quite interesting task... At first, I'd like to understand what do you mean saying

Quote
o wait untill exes (Driver.exe,set.exe) are set free..

Does "free" mean that it isn't executing now? If so all is clear Wink

This example of code look throught task list each 5 sec. and waits until $program_name isn't executing anymore.


Code
# Works only on Windows platform 

my $program_name = "Far.exe";

while ( 1 ) {
my @tasklist = `tasklist`;
last unless grep { /^$program_name/ } @tasklist;

# Program is running ...
print "$program_name is still busy... Wait for 5 sec.\n";
sleep 5;
}

print "$program_name is now free !!!";


After While-Loop you can place some code which will start $program_name for this process.

But be carefull!!! You shouldn't trust last print. It may lie. And I'll descrybe why. There is short time interval between last check and this print. Some concurent process can start $program_name during this interval. It is well known Race Conditions.


praveenbond3
New User

Apr 4, 2009, 10:11 AM

Post #3 of 5 (3030 views)
Re: [Tumata] [Advanced]Need a program that moniters .exe [In reply to] Can't Post

Hi,
Thanks for the code..

Basically I have two programs say A and B ..Both the programes require one exe..i,e Driver.exe to perform some tasks..but Driver.exe can be used by only one program at a time..say if Program A is using Driver.exe then Program B can not use Driver.exe..Program B can use Driver.exe only when Program A releases Driver.exe (Program A Stops using Driver.exe)


FishMonger
Veteran / Moderator

Apr 4, 2009, 10:46 AM

Post #4 of 5 (3028 views)
Re: [praveenbond3] [Advanced]Need a program that moniters .exe [In reply to] Can't Post

Win32::Process::Info - Provide process information for Windows 32 systems.
http://search.cpan.org/~wyant/Win32-Process-Info-1.013/lib/Win32/Process/Info.pm


Tumata
User


Apr 9, 2009, 1:46 AM

Post #5 of 5 (2989 views)
Re: [praveenbond3] [Advanced]Need a program that moniters .exe [In reply to] Can't Post

See flock function for implement locking. There is also example in perldoc (see perldoc -f flock).

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives