tags:

views:

46

answers:

2

I want to use ruby script for installing all the necessary things for a working rails environment.

I wonder how I could run

`sudo aptitude install <appname>`

and actually see the output generated just like if I ran that line in the command line.

And when I am prompted to type in something, then I can do that.

Is this possible?

Thanks

+4  A: 

Use system.

system 'sudo aptitude install <appname>'

It will return true if the command excecuted successfully, or false if there was an error. All output will be directed to $stdout/$stderr.

Adrian
A: 

As tiny correction to Adrian, these forms avoid shell escaping mess if appname contains any funny characters:

system 'sudo', 'aptitude', 'install', appname

system *%W[sudo aptitude install #{appname}]
taw