[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

windows commands and error handling

Brad Tilley

11/8/2006 7:17:00 PM

I am attempting to handle windows native command errors within a Ruby script on
windows xp. Commands in backticks like `net use ...` do not allow for this. I
tried open3, but it is unsupported on windows because of the lack of fork.
system() does not do anything either. How do others handle this on windows? I
only want to use the core Ruby library, not win32 utils.

begin
`windows command`
rescue SomeException => e
do this to handle this exception...
rescue SomeOtherException =>
do this for the other exception...
end

Thank you,
Brad



1 Answer

Wilson Bilkovich

11/8/2006 7:22:00 PM

0

On 11/8/06, Brad Tilley <rtilley@vt.edu> wrote:
> I am attempting to handle windows native command errors within a Ruby script on
> windows xp. Commands in backticks like `net use ...` do not allow for this. I
> tried open3, but it is unsupported on windows because of the lack of fork.
> system() does not do anything either. How do others handle this on windows? I
> only want to use the core Ruby library, not win32 utils.
>
> begin
> `windows command`
> rescue SomeException => e
> do this to handle this exception...
> rescue SomeOtherException =>
> do this for the other exception...
> end
>

Use "system" if you want the exit code of the system command you are
running. Use backticks if you need the output from the command you
invoked.

Does that help?