Forum: Ruby Just need a clue

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.
A5735ac216e523d16f3a238fb547ae7e?d=identicon&s=25 Alan (Guest)
on 2006-05-02 05:22
Hi,

I want to replace some DOS batch scripts with Ruby scripts.

Could you give me a clue how can I execute a .EXE file within Ruby
script and also how can I check the errorlevel?

Any help would be appreciated,
Alan
A402df36168b81b31c17adcbb5ae8cf4?d=identicon&s=25 Pistos Christou (pistos)
on 2006-05-02 06:47
Alan wrote:
> Hi,
>
> I want to replace some DOS batch scripts with Ruby scripts.
>
> Could you give me a clue how can I execute a .EXE file within Ruby
> script and also how can I check the errorlevel?
>
> Any help would be appreciated,
> Alan

See the various Kernel methods, such as system:

http://www.ruby-doc.org/core/classes/Kernel.html#M002992

"Executes cmd in a subshell, returning true if the command was found and
ran successfully, false otherwise. An error status is available in $?.
The arguments are processed in the same way as for Kernel::exec."
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-05-03 18:59
(Received via mailing list)
On May 1, 2006, at 11:22 PM, Alan wrote:

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

system("some.exe")
puts $? # will contain the exit code
This topic is locked and can not be replied to.