You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jim Anderson <j_...@yahoo.com> on 2005/03/17 03:38:12 UTC

Newbie: getting return code from sax.Counter in bash

Hi -

I am using Xerces in a shell script (bash) on Linux and Mac OS X.
I want to detect if sax.Counter gets a parse error or a 'file not
found' error.  First, I tried this:

    java sax.Counter -v myfile.xml
    echo $?

When I check the value of $? in the shell script, it always comes
back 0, so I cannot use the value to detect an error.

I am currently doing this:

    java sax.Counter -v myfile.xml > stdout.txt 2> stderr.txt

My shell script checks the file size of stderr.txt.  If the file
size is greater than zero, then it contains error messages, so
I assume that sax.Counter has encountered an error and the script
takes appropriate action.

Is this the best way to handle this error, or is there a better way?

Thanks.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Newbie: getting return code from sax.Counter in bash

Posted by James Shaw <he...@btopenworld.com>.
Jim Anderson wrote:

>Hi -
>
>I am using Xerces in a shell script (bash) on Linux and Mac OS X.
>
>  
>
[snip]

>I am currently doing this:
>
>    java sax.Counter -v myfile.xml > stdout.txt 2> stderr.txt
>
>My shell script checks the file size of stderr.txt.  If the file
>size is greater than zero, then it contains error messages, so
>I assume that sax.Counter has encountered an error and the script
>takes appropriate action.
>
>Is this the best way to handle this error, or is there a better way?
>
>Thanks.
>
>  
>
There are better ways, but IMO this isn't a Xerces issue. You're best 
off looking at some bash documentation, or seeking assistance from a 
bash help group.

James Shaw

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Newbie: getting return code from sax.Counter in bash

Posted by Andy Clark <an...@apache.org>.
Jim Anderson wrote:
> I am using Xerces in a shell script (bash) on Linux and Mac OS X.
> I want to detect if sax.Counter gets a parse error or a 'file not
> found' error.  First, I tried this:
> 
>     java sax.Counter -v myfile.xml
>     echo $?
> 
> When I check the value of $? in the shell script, it always comes
> back 0, so I cannot use the value to detect an error.

The Xerces samples aren't really meant to be used in production
systems. Even so, it probably would be worthwhile to have them
exit with meaningful status codes.

--
Andy Clark * andyc@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org