Execute command in windows command prompt from ruby code

Hello, I have the below two commands I run from the windows command
prompt. I would like to now call these two commands from my local ruby
script. How would I go about doing this?

% ipconfig /all > output.txt
% convert -size 100x100 image.tiff image.png (I've this tool in my path)

Thank-you in advance, michelle

/ASIDE:/
This specific question originated in a previous post. Since the answer
in isolation may be useful to many people I decided to create a new
separate post here.
see http://www.ruby-forum.com/topic/2364739#1016854

···

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

Use one of:

* system("yourcommand")
* `yourcommand` (these are backticks)
* spawn("yourcommand")

The differences:

* system waits until "yourcommand" has finished and outputs everything
  to $stdout. Then it returns true or false depending on the exitstatus.
* The backticks wait as well, but return the output made by the program.
* spawn doesn't wait, but rather returns the PID of the subprocess. Note
  that this requires Ruby 1.9 on Windows to work.

There's also exec("yourcommand"), but that's probably not what you want.
It replaces your Ruby process with "yourcommand". Oh, and IO.popen if
you need a pipeline to your process. :wink:

Vale,
Marvin

···

Am 16.08.2011 08:44, schrieb Michelle Pace:

Hello, I have the below two commands I run from the windows command
prompt. I would like to now call these two commands from my local
ruby script. How would I go about doing this?

% ipconfig /all > output.txt % convert -size 100x100 image.tiff
image.png (I've this tool in my path)

Thank-you in advance, michelle

/ASIDE:/ This specific question originated in a previous post. Since
the answer in isolation may be useful to many people I decided to
create a new separate post here. see
Converting .tiff -to-> .png? - Ruby - Ruby-Forum