For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2006 > need to return exit code









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author need to return exit code
Gregory Machin

2006-07-31, 3:57 am

Hi
My perl script is called by a bash script, used in a compile / build env.
But the bash script is not seeing my script's exit and is timming out and
continuing ...

How can I pass a standard exit code 0 = success 1 = fail to the operating
system / calling script.

Many Thanks

--
Gregory Machin
gregory.machin@gmail.com
www.linuxpro.co.za

Indraneel

2006-07-31, 3:57 am

More details might help better understanding the problem.. but i wrote
a perl script that does nothing but return with exit 0 or exit 1 and
called it from shell
sh-2.05b$ ` perl ~/test.pl`
sh-2.05b$ echo $?
1

It seems to work for me.

Prabu

2006-07-31, 3:57 am

Gregory Machin wrote:
> Hi
> My perl script is called by a bash script, used in a compile / build env.
> But the bash script is not seeing my script's exit and is timming out and
> continuing ...
>
> How can I pass a standard exit code 0 = success 1 = fail to the operating
> system / calling script.
>
> Many Thanks
>

Hello,

Hope this is something you are looking for...

#!/bin/sh
echo "Call Perl Program";
perl pro.pl
val=$?;
if [[ $val == 0 ]]
then
echo "Success $val";
else
echo "Fail $val";
fi

The $? will contain the exit status of the perl program(command).

--
Prabu.M.A
When I was born I was so surprised
I didnt talk for a period and half
-Gracie Allen

JupiterHost.Net

2006-07-31, 7:09 pm



Gregory Machin wrote:
> Hi


Hello,

> My perl script is called by a bash script, used in a compile / build env.
> But the bash script is not seeing my script's exit and is timming out and
> continuing ...
>
> How can I pass a standard exit code 0 = success 1 = fail to the operating
> system / calling script.


perldoc -f exit
Gregory Machin

2006-07-31, 7:09 pm

thanks for the support guys .. have a grate day ..

On 7/31/06, Prabu <prabu.ayyappan@gmail.com> wrote:
>
> Gregory Machin wrote:
> env.
> and
> operating
> Hello,
>
> Hope this is something you are looking for...
>
> #!/bin/sh
> echo "Call Perl Program";
> perl pro.pl
> val=$?;
> if [[ $val == 0 ]]
> then
> echo "Success $val";
> else
> echo "Fail $val";
> fi
>
> The $? will contain the exit status of the perl program(command).
>
> --
> Prabu.M.A
> When I was born I was so surprised
> I didnt talk for a period and half
> -Gracie Allen
>
>



--
Gregory Machin
gregory.machin@gmail.com
www.linuxpro.co.za

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com