how to run a command line command

S

shawn bright

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
 
D

Dale Martenson

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


There are a number of ways to accomplish this:

system( 'vim somefile' )

or

`vim somefile`

Note: those are back ticks by the way.
 
N

nephish

There are a number of ways to accomplish this:

system( 'vim somefile' )

or

`vim somefile`

Note: those are back ticks by the way.

cool enough, works great, thanks
sk
 
C

Chad Perrin

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?
 
S

Suraj Kurapati

Dale said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,236
Messages
2,571,184
Members
47,820
Latest member
HortenseKo

Latest Threads

Top