Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning value from Perl

Status
Not open for further replies.

divakarp

Programmer
Jun 28, 2004
4
0
0
US
Hi,

I am calling perl script from a Korn shell and catching the return value using $? in K shell script.

In the perl script I have followig statements. Actually my perl script does more than this but finally returns value 260 (may not be always the same number). I am coded it on Unix HP box.

--------------------
#!/usr/bin/perl

$a = 260;
exit $a ;

-----------------

It is returning value 4 instead of 260. Always returns actual value - 255. If the actual value is less than 255 then it looks fine.


All comments would be appreciated.

thanks.
Divakara.

 
it always does that, I think 255 is as high as it goes. it then starts back at 0. What I would do in your script is grab the standard output from the other script.

___________________________________
[morse]--... ...--[/morse], Eric.
 

Not sure I understood correctly.
Can you please explain me how you do that ?

thanks for your reply.



 
Well, what are you using to grab the return code from the script as it is to get that output? Just set it to grab the last bit of standard output.

___________________________________
[morse]--... ...--[/morse], Eric.
 

Now I use $? in K shell to grab the output from perl.

Any sample K shell code do you have ?


Appreciate your help.

 
well, to grab the output from the perl script you run:

kvariable=`perlscript.pl` will store the output in the variable, so if you want the perl script to output 260, $kvariable will become 260. HOw much output does your perl script get?

___________________________________
[morse]--... ...--[/morse], Eric.
 
of course, the alternate is to modify the perl code to return 0 (good) or 1-255 (various bads). In case its not obvious, *nix ret codes are 8 bits.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top