icfb nograph replay, and exit code

Discussion in 'Cadence' started by Marcel Preda, Apr 23, 2010.

  1. Marcel Preda

    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, Apr 23, 2010
    #1
  2. Marcel Preda wrote, on 04/23/10 08:42:
    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.
     
    Andrew Beckett, Apr 23, 2010
    #2
  3. Marcel Preda

    Guest Guest

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

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

    (for example).

    -Pete Zakel
    ()

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

    - Browning
     
    Guest, Apr 23, 2010
    #3
  4. Marcel Preda

    Marcel Preda Guest


    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
     
    Marcel Preda, Apr 23, 2010
    #4
  5. Marcel Preda

    Marcel Preda Guest

    Hi Pete,


    It looks to be what I want.

    Thank you very much,
    Marcel
     
    Marcel Preda, Apr 24, 2010
    #5
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 (here). After that, you can post your question and our members will help you out.