jerry wrote:
> As i understand it after running a command running "echo $?" will
> respond with 0 if the command executed properly and any other number if
> there were an error.
> 
> I keep getting the response 130; obviously an error. Where can i find a
> list  of error codes on linux?

Note that echo $? reports the exit-code returned by the last command, so
it is important not to interpose a unrelated command (such as even an
empty command followed by ENTER.

I'm not sure why there isn't an easier way to find out, but
 less /usr/include/asm/errno.h
let's me browse them on my system(s).

man errno just gives the symbolic names
man strerror _ought_ to give a mapping, I suppose

There is a perl module Errno.pm, but I haven't figured out how to use it.

It's not the  most convenient, but you can use python to translate a
number to a posix name and then use man errno to get descriptive info
(sheesh!)

 python -c'import errno;print errno.errorcode[7]'
But this only includes _standard_ errors up to (near) 127.


I thought that error codes over 128 meant something special (my
asm/errno.h stops at 124), but I can't recall what -- can somebody help
on this?

Anyway, here's a quickie c proglet to play with.
Cut and save as strerror.c, and build it from the command line in the
directory where you saved it with the simple default make command

 make strerror

That will will turn strerror.c into an executable strerror)

When I run this on my system, I get
  strerror(130) returns 'Owner died'
..but I'm still here!, so I think it's safe <heh>

===program-code===
#include <stdio.h>
//#include <errno.h>
#include <string.h>

#define BLEN 31

int main(){
 char ibuf[BLEN+1];
 int err;
 while (1){
    printf("\nEnter error number to lookup: (Just Enter to quit).. ? ");
    fgets(ibuf, BLEN, stdin);
    err = atoi(ibuf);
    if (!err)
        return 0;
    printf("strerror(%d) returns '%s'\n", err, strerror(err));
 }
}
===end code=======

Man it's been soooo long since I wrote any c. The above is probably not
up to best practice these days. Comments welcome

(I'd really prefer to write it in perl or python. Anybody help?)

..jim

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-newbie

Reply via email to