Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Find Running Process

by redlake2 (Initiate)
on Apr 10, 2012 at 06:58 UTC ( [id://964266]=perlquestion: print w/replies, xml ) Need Help??

redlake2 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I need some help. I need to check if a process is running and then continue on with some Perl code after the process completes. (I am going to use notepad.exe as an example app)

The Perl call prglst doesn't work for me so I wrote some DOS code that works sending the data through to a file that I can read:

set tempfile = "C:\Testing\TestNotepadRunning.txt"
tasklist > %tempfile%

Then transposing that call into Perl won't work for me:

my @tempfile = 'C:\Testing\TestNotepadRunning.txt'; system('TASKLIST > $tempfile');

Can you help?

Replies are listed 'Best First'.
Re: Find Running Process
by DrHyde (Prior) on Apr 10, 2012 at 09:55 UTC

    I could write your code for you, but that won't help you much. Instead I recommend that you go and read the Llama book. You need to learn about interpolation and what the @ and $ sigils mean.

    I'm also not sure what this 'prglst' that you speak of is. It's not part of perl.

Re: Find Running Process
by repellent (Priest) on Apr 10, 2012 at 07:16 UTC
    useautodie qw(:all);
    # single quotes here to keep the backslashes as-is my $tempfile = 'C:\Testing\TestNotepadRunning.txt'; # double quotes here to interpolate $tempfile system("TASKLIST > $tempfile");
Re: Find Running Process
by Anonymous Monk on Apr 10, 2012 at 07:06 UTC

    use double quotes because single quotes do not interpolate while double quotes do interpolate. perlintro and Modern Perl explain interplation.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://964266]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found