Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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
system PROGRAM 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928232]
help
Chatterbox?
[shmem]: no. You're right.
[msh210]: About time... last time I was right was... I don't even remember when.
[shmem]: perl -e 'warn "test$/", ^@^ '
[Eily]: well, at least it's right about warn doing the same thing as die :)
[shmem]: same with undef as last element
[msh210]: oh, good point. It's the best kind of correct
[shmem]: msh210: but I'd not call it a lie outright. That's when you do know the truth.
[msh210]: I don't have sendmail (I'm on MS Windows), so does one of you think you can report the bug?
[shmem]: msh210: 'tis about time to tell the sad truth to perl5porters - via perlbug
[msh210]: probably whoever wrote that actually knows the truth

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (15)
As of 2017-04-24 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.