Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Perl script to wait for a program to finish

by ww (Archbishop)
on Sep 28, 2011 at 03:46 UTC ( #928232=note: print w/replies, xml ) Need Help??

in reply to Perl script to wait for a program to finish

My guess: it'll be a lot easier to offer a good explanation if you show us your code.

If I understand what you wrote as you wrote it (intended?), your description doesn't match the way system works -- c.f. perldoc -f system:

system LIST
       Does exactly the same thing as "exec LIST", except that a fork
       is done first, and the parent process waits for the child
       process to exit. ....

Replies are listed 'Best First'.
Re^2: Perl script to wait for a program to finish
by pvaldes (Chaplain) on Sep 28, 2011 at 09:45 UTC

    I agree, this is probably a "faux" problem

    If you use system to open a program, i.e:

    `gimp`; print "gimp was closed\n"; print "... lots and lots of commands next";

    the script is stopped until the first line is finished, so the second, third etc lines, are "frozen" and never run until you close manually this gimp session.

     delete a folder which is created by this program after it gets closed by the user

    It depends on your specific case, you could need to add another system line below doing the cleanup, a rmdir $dir line, or nothing

Re^2: Perl script to wait for a program to finish
by renzosilv (Novice) on Sep 28, 2011 at 15:02 UTC
    Sorry I didn't show any code. Is just a few lines long so I didn't think it was necessary. Example: system ("vp -e " . $ENV{'VREL'}); rm /home/$ENV{'verl'}; the problem is my program is dying when the user closes my vp program. I never get to the remove directory. I tried printing for debugging purposes also but my program is dying on that line.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928232]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2018-03-22 23:43 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (286 votes). Check out past polls.