Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Find Running Process

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

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


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?

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
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2023-10-01 02:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found