gnuplot error code

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

gnuplot error code

Plotter-2
Hi,

I am calling gnuplot as a child process and need to conditionally return
a non zero error code in some circumstances. From a quick search it
seems that this is not possible, It always returns zero: yet that seems
a little surprising.

perl -e 'system("gnuplot -e \"exit 1;\""); print "$?\n"'

The only way I can get a non zero result is if there is a parsing error
in the gnuplot commands.

I am using gnuplot to display real time data on a server and it would be
good to be able to do some basic error trapping, not least for
debugging. Is there a way to do this?

Thanks, Peter.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: gnuplot error code

sfeam
On Saturday, 04 February 2017 01:17:25 AM : [hidden email] wrote:

> Hi,
>
> I am calling gnuplot as a child process and need to conditionally return
> a non zero error code in some circumstances. From a quick search it
> seems that this is not possible, It always returns zero: yet that seems
> a little surprising.
>
> perl -e 'system("gnuplot -e \"exit 1;\""); print "$?\n"'
>
> The only way I can get a non zero result is if there is a parsing error
> in the gnuplot commands.
>
> I am using gnuplot to display real time data on a server and it would be
> good to be able to do some basic error trapping, not least for
> debugging. Is there a way to do this?

Correct. There is no way to control the gnuplot exit value.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: gnuplot error code

Plotter-2
On 04/02/17 04:14, sfeam wrote:

> On Saturday, 04 February 2017 01:17:25 AM : [hidden email] wrote:
>> Hi,
>>
>> I am calling gnuplot as a child process and need to conditionally return
>> a non zero error code in some circumstances. From a quick search it
>> seems that this is not possible, It always returns zero: yet that seems
>> a little surprising.
>>
>> perl -e 'system("gnuplot -e \"exit 1;\""); print "$?\n"'
>>
>> The only way I can get a non zero result is if there is a parsing error
>> in the gnuplot commands.
>>
>> I am using gnuplot to display real time data on a server and it would be
>> good to be able to do some basic error trapping, not least for
>> debugging. Is there a way to do this?
>
> Correct. There is no way to control the gnuplot exit value.
>
>

Thanks for the confirmation, Ethan.

Would this be a worthwhile feature to add? I'm thinking of something
like the awk exit which allows an optional  integer argument to  return.

if ( ! happy ) { print "not happy" ; exit 1; )

gnuplot is an excellent tool for plotting real time data on embedded
devices to provide real time graphic output but obviously the
possibility to exit with an error condition can be helpful, firstly in
debugging and also trapping possible error conditions with a meaningful
response should they happen.

The current behaviour is just jexit 0 , for backwards compat, some
thought would need to be given to current non zero return in case of a
syntax error in a gnuplot script but this does not seem to raise any
conflict for those trapping current behaviour.

Peter.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: gnuplot error code

sfeam
On Saturday, 04 February 2017 09:38:31 AM [hidden email] wrote:

> On 04/02/17 04:14, sfeam wrote:
> > On Saturday, 04 February 2017 01:17:25 AM : [hidden email] wrote:
> >> Hi,
> >>
> >> I am calling gnuplot as a child process and need to conditionally return
> >> a non zero error code in some circumstances. From a quick search it
> >> seems that this is not possible, It always returns zero: yet that seems
> >> a little surprising.
> >>
> >> perl -e 'system("gnuplot -e \"exit 1;\""); print "$?\n"'
> >>
> >> The only way I can get a non zero result is if there is a parsing error
> >> in the gnuplot commands.
> >>
> >> I am using gnuplot to display real time data on a server and it would be
> >> good to be able to do some basic error trapping, not least for
> >> debugging. Is there a way to do this?
> >
> > Correct. There is no way to control the gnuplot exit value.
> >
> >
>
> Thanks for the confirmation, Ethan.
>
> Would this be a worthwhile feature to add?

Sure.  But I have no idea how we would do it.
Adding a command "exit <status>" would not help so far as I can see,
because in order to execute that command the program must be
in a non-error state. So the only code it makes sense to emit is 0.

If there is a serious error like segfault or divide-by-zero the
program exits via the system fault-handling and gnuplot's normal
exit routine is not invoked.  If there is a non-fatal error
(read past end-of-file, say) gnuplot handles this internally and
by the time it is ready to parse a new command like "exit" the
error state no longer exists.

What sort of error do you imagine reporting?

        Ethan



> I'm thinking of something
> like the awk exit which allows an optional  integer argument to  return.
>
> if ( ! happy ) { print "not happy" ; exit 1; )
>
> gnuplot is an excellent tool for plotting real time data on embedded
> devices to provide real time graphic output but obviously the
> possibility to exit with an error condition can be helpful, firstly in
> debugging and also trapping possible error conditions with a meaningful
> response should they happen.
>
> The current behaviour is just jexit 0 , for backwards compat, some
> thought would need to be given to current non zero return in case of a
> syntax error in a gnuplot script but this does not seem to raise any
> conflict for those trapping current behaviour.
>
> Peter.
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> gnuplot-beta mailing list
> [hidden email]
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
gnuplot-beta mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta