0

Is there anyway to write commands to the command prompt in windows and execute directly from a ruby program?

I would use this as a one click installer for all the gems I wanted to install on the computer after installing ruby. I hope that it would save time when transferring my ruby files to a new computer. Or would be an easier way to get a non-ruby person set up very quickly with all the gems I thought them might need.

I am imagining something like Watir but for the Cmd rather than a browser.

EDIT

Thanks to

How can I then close the cmd window without closing the program for instance:

'notepad'

starts a cmd window and it also starts notepad but the cmd windows stays until the notepad is closed.

1

1 Answer 1

3

Ruby will execute anything you put in backticks ` in your associated shell.

so if you type

test = `ipconfig`
puts test

test should now have stored in it the data from the cmd call ipconfig

EDIT

You can also use the System(..) call in Ruby to execute commands

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

1 Comment

why does it give me file "'def_wrap=R,def_wrap_guard=R' not found" before putting the program?

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.