[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how to run a command line command

shawn bright

3/5/2007 6:22:00 PM

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

5 Answers

Dale Martenson

3/5/2007 7:42:00 PM

0

On Mar 5, 12:22 pm, "shawn bright" <neph...@gmail.com> wrote:
> 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.


shawn bright

3/5/2007 7:52:00 PM

0

On Mar 5, 1:41 pm, "Dale Martenson" <dale.marten...@gmail.com> wrote:
> On Mar 5, 12:22 pm, "shawn bright" <neph...@gmail.com> wrote:
>
> > 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.

cool enough, works great, thanks
sk

Wang Dong

3/6/2007 2:53:00 AM

0

also %x(vim somefile)

"nephish" <nephish@gmail.com>
??????:1173124322.870599.25150@h3g2000cwc.googlegroups.com...
> On Mar 5, 1:41 pm, "Dale Martenson" <dale.marten...@gmail.com> wrote:
>> On Mar 5, 12:22 pm, "shawn bright" <neph...@gmail.com> wrote:
>>
>> > 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.
>
> cool enough, works great, thanks
> sk
>


Chad Perrin

3/6/2007 3:00:00 AM

0

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?

--
CCD CopyWrite Chad Perrin [ http://ccd.ap... ]
Ben Franklin: "As we enjoy great Advantages from the Inventions of
others we should be glad of an Opportunity to serve others by any
Invention of ours, and this we should do freely and generously."

Suraj Kurapati

3/6/2007 7:11:00 AM

0

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?

--
Posted via http://www.ruby-....