Forum: Ruby Exiting a ruby script

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bcf82614395ca5033438c7b6047da721?d=identicon&s=25 Jason Burgett (jasbur)
on 2007-03-11 19:23
I'm in the process of playing around with a, application launcher
script. It's fairly far along, but I can't seem to get the script to
exit when the application is actually launched. Here's the final bit of
code:

@finalApps.each {|finalApp| if finalApp.id == runApp.to_i
                                updateRanking finalApp.name
                                symbolMatch = finalApp.command.match(/
%/)
                                if symbolMatch
                                  system(symbolMatch.pre_match)
                                else
                                  system(finalApp.command)
                                end
                              end
                  }

There's some extra stripping of the command in there. The functional
part is the internal if loop. After "system(symbolMatch.pre_match)" or
"system(finalApp.command)" the app launches properly, but in the console
the ruby script stays open until the app is closed.

Is there a way to get the ruby script to terminate immediately after the
app is successfully launched?
C40020a47c6b625af6422b5b1302abaf?d=identicon&s=25 Stefano Crocco (crocco)
on 2007-03-11 20:28
(Received via mailing list)
Alle domenica 11 marzo 2007, Jason Burgett ha scritto:
>                                   system(symbolMatch.pre_match)
>
> Is there a way to get the ruby script to terminate immediately after the
> app is successfully launched?

If I understand your problem correctly, you should use exec instead of
system,
which replace the ruby interpreter with the command given as argumnt.

I hope this helps

Stefano
Bcf82614395ca5033438c7b6047da721?d=identicon&s=25 Jason Burgett (jasbur)
on 2007-03-13 17:01
Actually, the process still holds open while the "launched" app running.
As soon as that last enter key is pressed to launch the app I need the
ruby script to release the console.


> If I understand your problem correctly, you should use exec instead of
> system
This topic is locked and can not be replied to.