cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Is error checking from `` possible?

ptc-4742614
1-Newbie

Is error checking from `` possible?

When I run a command like:

local $value = `fake_program_name`

I get nothing back in $value, $main::sh_status is set to 0. $sh_status is empty. $main::ERROR is empty. Is there any way to actually check to see an error?

(fake_program_name doesn't exist, which seems like a way to generate a pretty obvious error)

1 REPLY 1

Hi Mike--

The problem with this is that the backtick syntax returns any text that goes to standard output in the OS, but in the case you describe (missing executable), the messages go to standard error instead.

On Windows, you can get around this by explicitly redirecting standard error to standard output as part of your command. For example, if you do this:

response(`bogus`)

you won't get any result, because Windows sends its complaints to standard error. If you include the redirection, by including "2>&1" at the end of your command, you will get the error message (assuming one is generated). For example, if you do this:

response(`bogus 2>&1`)

you will see the error message in your alert box:

bogus.png

--Clay

Announcements

Top Tags