Hi Gerald and thank you for your reply.

Now I get 255 when the exit code should be 0. I'm afraid I don't
understand the bit shifting fully so I'm not sure what to do next.

I also get 255 if it's unsucessful.

i'm using tar to extract some files, and tar returns 0 upon sucess and 2
on failure.

On Sat, Jul 16, 2005 at 10:16:00PM +0200, Gerald Richter wrote:
> > 
> > Sometimes I see strange numbers when handling exit status 
> > from system calls.
> > 
> >     my $out = `$cmd`;
> >     my $stat = $? >> 8;
> > 
> > and $stat may contain anumber like  16777215 at this point, 
> > whereas on commandline it would be more like 2, or no error 
> > at all (0).
> > 
> 
> Looks like that the number get sign extented, try
> 
> my $stat = ($? >> 8) & 0xff ;
> 
> Gerald
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to