Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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]
[ovedpo15]: another question about regex. if I have a string like this: "a/b/,c/d/e,5" I would like to remove the string after the last comma so the output will be "a/b/,c/d/e" how to do so?
[Corion]: ovedpo15: You could split on comma, and then join everything together, except the last part. Or you could match and make sure that the last part has no comma, like qr!,[^,]+$!, or you could use rindex.
[ovedpo15]: But I don't know the length of the string. will it still work?
[ovedpo15]: The only thing I know is that there is a comma at the end and a value after that
[hippo]: Try it and see. Your computer won't explode.
[Corion]: length will tell you the length of a string.
[Corion]: But if you are parsing CSV, again, let me point to Text::CSV_XS, which you should use instead

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2018-05-27 10:36 GMT
Find Nodes?
    Voting Booth?