How to run a command line command


#1

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


#2

On Mar 5, 1:41 pm, “Dale M.” removed_email_address@domain.invalid wrote:

Note: those are back ticks by the way.

cool enough, works great, thanks
sk


#3

also %x(vim somefile)

“nephish” removed_email_address@domain.invalid
???:removed_email_address@domain.invalid…


#4

On Mar 5, 12:22 pm, “shawn bright” removed_email_address@domain.invalid 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.


#5

Dale M. wrote:

On Mar 5, 12:22 pm, “shawn bright” removed_email_address@domain.invalid 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?


#6

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?