1

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

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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}]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.