# Just need a clue

**URL:** <https://www.ruby-forum.com/t/just-need-a-clue/94363>\
**Category:** Ruby\
**Created:** [May 2, 2006, 5:22am UTC](https://www.ruby-forum.com/t/just-need-a-clue/94363 "2006-05-02T05:22:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@alan](https://www.ruby-forum.com/u/alan)\
**Post date:** [May 2, 2006, 5:22am UTC](https://www.ruby-forum.com/t/just-need-a-clue/94363/1 "2006-05-02T05:22:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@alan](https://www.ruby-forum.com/u/alan)\
**Post date:** [May 2, 2006, 6:47am UTC](https://www.ruby-forum.com/t/just-need-a-clue/94363/2 "2006-05-02T06:47:53Z")

</div>

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](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.”

---

<div class="post-metadata">

**Author:** ![alan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@alan](https://www.ruby-forum.com/u/alan)\
**Post date:** [May 3, 2006, 6:59pm UTC](https://www.ruby-forum.com/t/just-need-a-clue/94363/3 "2006-05-03T18:59:10Z")

</div>

On May 1, 2006, at 11:22 PM, Alan wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

system(“some.exe”)  
puts $? # will contain the exit code
