Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Determine if a program in a different terminal has ended

by renegadex (Beadle)
on Sep 17, 2009 at 11:41 UTC ( [id://795859]=note: print w/replies, xml ) Need Help??


in reply to Re: Determine if a program in a different terminal has ended
in thread Determine if a program in a different terminal has ended

the myscript.pl takes a long time to finish and it also depends on the userinputs, it also has its own gui and other stuff. so everytime I run that script, it waits for user input such as button presses and other stuff... using a sleep() would be useless because the time that the script would finish is unknown. if there would be a way for the myscript.pl to send a signal or something that can be captured by the main script, maybe that might work? hehe but i don't know any...
Mabuhay Civil Engineers! :D
  • Comment on Re^2: Determine if a program in a different terminal has ended

Replies are listed 'Best First'.
Re^3: Determine if a program in a different terminal has ended
by almut (Canon) on Sep 17, 2009 at 11:52 UTC
    using a sleep() would be useless

    I just put the sleep in there for testing purposes, i.e. to emulate a script doing something that takes time... (if the script doesn't do anything, the terminal would of course also close immediately)

    I still wonder what's happening in your case.  The "normal" thing for a terminal would be to wait until the command it runs has finished...

    What happens on your system when you try

    for (1..3) { system("gnome-terminal -e 'sleep 2'"); }
      For demonstration, try this... I'm having trouble explaining my situation hehehehe
      # myscript.pl # # script must be run in a terminal # use Gtk2 '-init'; my $window = Gtk2::Window->new(); $window->signal_connect( destroy => sub { exit } ); my $button = Gtk2::Button->new("click me to close"); $button->signal_connect('clicked'=> sub { exit } ); $window->add($button); $window->show_all(); Gtk2->main;

      next is the main code
      # main.pl # my $k = 0; while($k < 3){ system("gnome-terminal -e 'perl myscript.pl'"); $k++; }

      if i ran main.pl it call the script 3x then ends... yet the first myscript.pl has not yet finished running... it waits for you to press the button... what i wanted to do is... open the 1st myscript.pl then wait for somebody to press it... then if somebody presses it, another myscript.pl would run again.. then so on..
      Mabuhay Civil Engineers! :D

        Works for me as expected, i.e. the program waits util I click the close button in your GUI, then the next instance (of terminal and GUI) is started...   (in this particular case, a terminal wouldn't even be required)

        Do you in fact get three instances of the GUI running at the same time?

      i cant see my post... sorry... i reposted another one below.. which i cant see either!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://795859]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-24 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found