Forum: Ruby how to run a command line command

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.
500e92cfb666d6757c317a5df7c7e28d?d=identicon&s=25 Shawn Bright (nephish)
on 2007-03-05 19:23
(Received via mailing list)
lo there all
i have an app that i want to launch an application from.
i use linux with a bash shell. If i want to launch a program from my
terminal, i use
./myprogram
or  /home/myuser/myprogram

how could i do something like this from a ruby script ?

thanks
sk
A083f2c63fc0be7f8f19006c9dbdff86?d=identicon&s=25 Dale Martenson (dale)
on 2007-03-05 20:45
(Received via mailing list)
On Mar 5, 12:22 pm, "shawn bright" <neph...@gmail.com> wrote:
> sk
There are a number of ways to accomplish this:

     system( 'vim somefile' )

or

     `vim somefile`

Note: those are back ticks by the way.
500e92cfb666d6757c317a5df7c7e28d?d=identicon&s=25 Shawn Bright (nephish)
on 2007-03-05 20:55
(Received via mailing list)
On Mar 5, 1:41 pm, "Dale Martenson" <dale.marten...@gmail.com> wrote:
>
>
> Note: those are back ticks by the way.

cool enough, works great, thanks
sk
2bc9162887ddb98d9b19bf404d3afb22?d=identicon&s=25 Dong Wang (wangdong2)
on 2007-03-06 03:55
(Received via mailing list)
also %x(vim somefile)

"nephish" <nephish@gmail.com>
??????:1173124322.870599.25150@h3g2000cwc.googlegroups.com...
Fd22ee3cfc7dac283ce8e451af324f7d?d=identicon&s=25 Chad Perrin (Guest)
on 2007-03-06 04:00
(Received via mailing list)
On Tue, Mar 06, 2007 at 11:55:09AM +0900, Wang Dong wrote:
> also %x(vim somefile)

I wonder how that one escaped my attention.  Thanks for mentioning it.

How does it work?  Like ``, or system(), or . . . what?
Bc368ef524130e8d0deb386de961e24a?d=identicon&s=25 Suraj Kurapati (snk)
on 2007-03-06 08:10
Dale Martenson wrote:
> On Mar 5, 12:22 pm, "shawn bright" <neph...@gmail.com> wrote:
>> sk
> There are a number of ways to accomplish this:
>
>      system( 'vim somefile' )
>
> or
>
>      `vim somefile`
>
> Note: those are back ticks by the way.

I avoid the latter unless I need the output generated by the command. By
doing so, I bypass a bunch of needless processing (capture command's
STDOUT to a newly allocated string buffer), or so I think. Does anyone
know for sure?
This topic is locked and can not be replied to.