icfb nograph replay, and exit code

M

Marcel Preda

Guest
Hi there,

I have one question about executin from other script:
icfb -nograph -replay my_script.il
Is it possible to get an exit code other then 0(zero) if in
my_script.il is a syntax error , or some other "programming" problem?

In a few words:
- I have a perl script whchi creates on the fly my_script.pl
- I exec my_script.il from that perl script using system("icfb -
nograph -replay my_script.il")
No the problem:
I may have some situations where I get ERROR, but script is running
and in the end the exit code is 0.
E.g., I may have:
- syntax error
- nil involved in arithmetic expressions: "nil + <a_number>"
- access some prop of a nil/unbound var: "nil->some_property"

Is it possible that in case of such errors the script to stop the
execution and to exit with a code different than 0 ?


Thank you,
Marcel
 
Marcel Preda wrote, on 04/23/10 08:42:
Hi there,

I have one question about executin from other script:
icfb -nograph -replay my_script.il
Is it possible to get an exit code other then 0(zero) if in
my_script.il is a syntax error , or some other "programming" problem?

In a few words:
- I have a perl script whchi creates on the fly my_script.pl
- I exec my_script.il from that perl script using system("icfb -
nograph -replay my_script.il")
No the problem:
I may have some situations where I get ERROR, but script is running
and in the end the exit code is 0.
E.g., I may have:
- syntax error
- nil involved in arithmetic expressions: "nil +<a_number>"
- access some prop of a nil/unbound var: "nil->some_property"

Is it possible that in case of such errors the script to stop the
execution and to exit with a code different than 0 ?


Thank you,
Marcel
Hi Marcel,

I tend to use:

icfb -nograph -restore script.il

rather than -replay. However, it should work nevertheless.

If you explicitly call:

exit()

it will exit with exit status 0. If you do:

exit(2)

it will exit with exit status 2.

Regards,

Andrew.
 
In article <5d3b83a7-2dd7-48f4-9eef-bb025926c735@29g2000yqp.googlegroups.com> Marcel Preda <marcel.preda@gmail.com> writes:
Hi there,

I have one question about executin from other script:
icfb -nograph -replay my_script.il
Is it possible to get an exit code other then 0(zero) if in
my_script.il is a syntax error , or some other "programming" problem?

In a few words:
- I have a perl script whchi creates on the fly my_script.pl
- I exec my_script.il from that perl script using system("icfb -
nograph -replay my_script.il")
No the problem:
I may have some situations where I get ERROR, but script is running
and in the end the exit code is 0.
E.g., I may have:
- syntax error
- nil involved in arithmetic expressions: "nil + <a_number>"
- access some prop of a nil/unbound var: "nil->some_property"

Is it possible that in case of such errors the script to stop the
execution and to exit with a code different than 0 ?
Instead of replaying my_script.il, replay a script that contains:

unless(errsetstring("load(\"my_script.il\")") exit(2))
exit()

(for example).

-Pete Zakel
(phz@seeheader.nospam)

How good is life, the mere living!
How fit to employ all the heart
and the soul and the senses
forever in joy

- Browning
 
On Apr 23, 5:56 pm, Andrew Beckett <andr...@DcEaLdEeTnEcTe.HcIoSm>
wrote:
Marcel Preda wrote, on 04/23/10 08:42:



Hi there,

I have one question about executin from other script:
icfb -nograph -replay my_script.il
Is it possible to get an exit code other then 0(zero) if in
my_script.il is a syntax error , or some other "programming" problem?

In a few words:
- I have a perl script whchi creates on the fly my_script.pl
- I exec my_script.il from that perl script using system("icfb -
nograph -replay my_script.il")
No the problem:
I may have some situations where I get ERROR, but script is running
and in the end the exit code is 0.
E.g., I may have:
  - syntax error
  - nil involved in arithmetic expressions: "nil +<a_number>"
  - access some prop of a nil/unbound var:  "nil->some_property"

Is it possible that in case of such errors the script to stop the
execution and to exit with a code different than 0 ?

Thank you,
Marcel

Hi Marcel,

I tend to use:

icfb -nograph -restore script.il

rather than -replay. However, it should work nevertheless.

If you explicitly call:

exit()

it will exit with exit status 0. If you do:

exit(2)

it will exit with exit status 2.

Regards,

Andrew.

Hi Andrew,

I'm not sure if I was able to explain what I want to do....

Let's suppose that I have next piece of code:
;;;;;;;;;;;;;;;;
;; File test.il
let( (foo)
println("I'm here 1!")
println(foo + 4) ;; foo is nil
println("I'm here 2!")
exit(0)
)
;;;;;;;;;;;;;

If I run "icfb -nograph -replay test.il"
Script is printing "I'm here 1";
Because skill wants to do "plus(nil 4)" it rise an error message:
;;;;;;;;;;;;;;;
*Error* plus: can't handle (nil + 4)
*Error* load: error while loading file - "/.../test.il"
;;;;;;;;;;;;;
But the exit code is 0.
I want if is possible something different that 0.


I've try also "icfb -nograph -restore test.il".
What I've noticed in this case: the script print "I'm here 1!".
It's printing the error message,
and after that it shows me the skill/icfb prompt and it's waiting for
skill commands.
I did not know until now how is working -restore switch.

Anyway in the end looks like I've found the solution, with your
help :)
Based on idea that if the script has an error the icfb interpreter
will wait for some input, why not to send it from the shell ?!
I just call from my script: "echo 'exit(111)' | icfb -nograph -restore
test.il"
In this way if everything is fine I have 0 as exit code,
if something went wrong I have 111 as exit code.
Already tested on IC5.1.41
It seems to work.

Anyway I'm still searching for a more elegant solution.


BR,
Marcel
 
On Apr 24, 1:06 am, px...@cadence.com (Pete nospam Zakel) wrote:
In article <5d3b83a7-2dd7-48f4-9eef-bb025926c...@29g2000yqp.googlegroups.com> Marcel Preda <marcel.pr...@gmail.com> writes:



Hi there,

I have one question about executin from other script:
icfb -nograph -replay my_script.il
Is it possible to get an exit code other then 0(zero) if in
my_script.il is a syntax error , or some other "programming" problem?

In a few words:
- I have a perl script whchi creates on the fly my_script.pl
- I exec my_script.il from that perl script using system("icfb -
nograph -replay my_script.il")
No the problem:
I may have some situations where I get ERROR, but script is running
and in the end the exit code is 0.
E.g., I may have:
- syntax error
- nil involved in arithmetic expressions: "nil + <a_number>"
- access some prop of a nil/unbound var:  "nil->some_property"

Is it possible that in case of such errors the script to stop the
execution and to exit with a code different than 0 ?

Instead of replaying my_script.il, replay a script that contains:

    unless(errsetstring("load(\"my_script.il\")") exit(2))
    exit()

(for example).

-Pete Zakel
 (p...@seeheader.nospam)

                How good is life, the mere living!
                How fit to employ all the heart
                and the soul and the senses
                forever in joy        

                            - Browning
Hi Pete,


It looks to be what I want.

Thank you very much,
Marcel
 

Welcome to EDABoard.com

Sponsor

Back
Top