bedanta has asked for the wisdom of the Perl Monks concerning the following question:

How does a PERL script return an exit code and we catch that exit code in a shell script?

Replies are listed 'Best First'.
Re: EXIT code
by Sidhekin (Priest) on Jan 11, 2005 at 09:51 UTC

    I don't know PERL, but this is how you do it in Perl (with perl) and catch it in the a shell. (And as a bonus, even echo the caught value.)

    perl -e 'exit 5' ; perl_exit_code=$? ; echo $perl_exit_code

    HTH,

    Update: Yup, gaal is right. In this context, "the shell" does not exist. I have modified my answer accordingly.

    print "Just another Perl ${\(trickster and hacker)},"
    The Sidhekin proves Sidhe did it!

      You mean, that is how to do it in Bourne and Bourne-ish shells. In c shells the value is in $status; in others, who knows?
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: EXIT code
by blazar (Canon) on Jan 11, 2005 at 11:14 UTC
    No such a thing as "PERL". Please check
    perldoc -q '"perl" and "Perl"'
    
    To answer your question:
    perldoc -f exit
    

      Sidhekin already mentioned the spelling. Nice refering the faq though.

      But perldoc -f exit doesn't help the OP much.
      You're right - I was mistaken, I'm sorry.

      Cheers, Sören