Re: Return codes ??

2001-04-19 Thread Michael D. Schleif


> "Capacio, Paula J" wrote:
> 
> I have a perl script (driver) that calls another script to unit
> test the conditional exits of that script.  The driver script is
> executed via a command window on NT and on a basic level the driver
> script code is
> @output = `perl rctest.pl`;
> if ($? != 0)
>{ print "return code: $?\n";}
> 
> What happens is...a exit 50; statement results in $? = 12800.
> 
> Why does this happen?  A friend told me that the cheat is to divide
> the value by 256 and you have the original value, and that
> worksbut why is this necessary?

See perlvar: ``Note that this is the status word returned by the wait()
system call (or else is made up to look like it). Thus, the exit value
of the subprocess is actually ($? >> 8), and $? & 127 gives which
signal, if any, the process died from, and $? & 128 reports whether
there was a core dump.''

This is a cross platform standard, by which you can get to *all* error
information available to the OS.  Unfortunately, certain OS's prefer to
obfuscate some information; and, some prefer not to give cli access to
signals . . .

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Return codes ??

2001-04-19 Thread Andy Jennings
Title: PSCI_1



Paula
 
Most likely because the command returns a two byte 
int and the return code is only setting the high byte bits with all the low byte 
bits unset.
 
Dividing by 256 is the equivalent of 8 bitwise 
shifts to place all the set bits in the low byte.
 
Andy
 

  - Original Message - 
  From: 
  Capacio, Paula 
  J 
  To: [EMAIL PROTECTED] 
  
  Sent: Thursday, April 19, 2001 6:42 
  PM
  Subject: Return codes ??
  
  I have a perl 
  script (driver) that calls another script to unit test the 
  conditional exits of that script.  The driver script is executed via a 
  command window on NT and on a basic level the driver script code 
  is  
  @output = `perl 
  rctest.pl`;
  if ($? != 
  0)   { print "return code: $?\n";}
   
  What happens 
  is...a exit 50; statement results in $? = 12800.  
   
  Why does this 
  happen?  A friend told me that the cheat is to divide the value by 
  256 and you have the original value, and that worksbut why is this 
  necessary?  
   
  TIA
  Paula 
  Capacio
    
     
   
   
   
   


Re: Return codes ??

2001-04-19 Thread $Bill Luebkert

> "Capacio, Paula J" wrote:
> 
> I have a perl script (driver) that calls another script to unit test the conditional 
>exits of that script.  The driver script is executed via a command window on NT and 
>on a basic level the driver script code is
> @output = `perl rctest.pl`;
> if ($? != 0)
>{ print "return code: $?\n";}
> 
> What happens is...a exit 50; statement results in $? = 12800.
> 
> Why does this happen?  A friend told me that the cheat is to divide the value by 256 
>and you have the original value, and that worksbut why is this necessary?

It's a UNIX thingy.  You can check the UNIX man pages out to see 
what the entire return code is or check sys/wait.h and bits/waitstatus.h 
headers to see how the other byte is used to show signal info etc.

-- 
  ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
 (_/   /  )// //   DBE Collectibles   http://www.todbe.com/
  / ) /--<  o // //  Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
-/-' /___/_<_http://www.freeyellow.com/members/dbecoll/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Return codes ??

2001-04-19 Thread Capacio, Paula J
Title: PSCI_1



I have a perl script 
(driver) that calls another script to unit test the 
conditional exits of that script.  The driver script is executed via a 
command window on NT and on a basic level the driver script code 
is  
@output = `perl 
rctest.pl`;
if ($? != 
0)   { print "return code: $?\n";}
 
What happens is...a 
exit 50; statement results in $? = 12800.  
 
Why does this 
happen?  A friend told me that the cheat is to divide the value by 256 
and you have the original value, and that worksbut why is this 
necessary?  
 
TIA
Paula 
Capacio