Forum: Ruby DOS cmd from .rb file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Xx X. (Guest)
on 2008-12-12 04:48
hi all, i try to invoke some DOS cmd from .rb file but to no avail.
Anyway, can i do that?
unknown (Guest)
on 2008-12-12 09:45
(Received via mailing list)
Like this?:

ans = %x[dir]
puts ans

Then take a look at:
- %x
- system()
- exec()
- ``

- Axel
Dan D. (Guest)
on 2008-12-12 19:18
(Received via mailing list)
system("dir")

or

result=`dir`

In the second example those are back ticks (left of the 1 key) not
single quotes.
This topic is locked and can not be replied to.