ruby bring up cmd prompt windows

A

arose

What would I have to do to get Ruby to do the equivalent of typing cmd
in Windows Run and then interacting with the command prompt?

I'm looking at some automation of running commands from the dos prompt.
 
A

arose

Ok I half way understand what you are saying, I'm experimenting..

I haven't used the ` character yet in Ruby
Have time to explain it to me?

You have responded to a large number of my elementary questions,
thanks.
 
M

Martin DeMello

arose said:
Ok I half way understand what you are saying, I'm experimenting..

I haven't used the ` character yet in Ruby
Have time to explain it to me?

It's inherited from unix shells - `command` executes the command and
captures its STDOUT. Try a = `dir`; puts a

martin
 
A

arose

cool, i didn't know that. Still seem to have some difficulties.

puts `dir` works

puts `dir c:\ruby` (or any other directory besides the one i'm in) does
not gives me file not found error; volume in drive c has no label.

why is this?
 
M

Martin DeMello

arose said:
cool, i didn't know that. Still seem to have some difficulties.

puts `dir` works

puts `dir c:\ruby` (or any other directory besides the one i'm in) does
not gives me file not found error; volume in drive c has no label.

why is this?

not sure - might be a windows thing, or just an escaping problem. try it
with a forward slash instead of the backslash, or try c:\\ruby.

martin
 
A

arose

puts `dir "c:\\ruby"` works


Jeffrey said:
Apparently, Ruby backquotes impose double-quote-style interpolation,
such that '\r' becomes a carriage return. I don't see this documented
anywhere, but I haven't checked the source...

irb(main):012:0> `echo #{"hello"}`
=> "hello\n"
 
A

arose

ok this is way harder than i thought it would be. I thought a good
first program would be to write a ruby program that gets the
Class.method information through ri and made the html for me. I am
struggling with the cmd prompt.

for starters i tried this:
puts `ri "-Tf html String#gsub > gsub.html"`

I get an exec format error

tried this
puts `ri` and that returns the same error

puts `"ri -Tf html String#gsub > gsub.html"`
gives me a no such directory error.

any advice?


I can
 
A

arose

Too easy. Thanks man.


Tim said:
fyi, you'll get a lot of html documents, and many of them will be blank.
That's not an error. Those methods are documented in IO.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,627
Members
45,328
Latest member
66Teonna9

Latest Threads

Top