windows commands and error handling

B

Brad Tilley

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
 
W

Wilson Bilkovich

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?
 

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
474,141
Messages
2,570,813
Members
47,357
Latest member
sitele8746

Latest Threads

Top