Is there a command-line tool that will take a symbolic errno such as EINVAL
and print the corresponding string, Invalid argument
?
I would like to avoid having to find that EINVAL is value 22 on my system and then using$ perror 22
.
Ideally I could write something like
$ errorcommand EINVAL
Invalid argument
$
This works on Ubuntu 9.04:
You can also try a Python script:
The function
Is possibly what you're looking for, but I don't know of a command that exposes that to any shell offhand.
MKS exposes the command line
strerror
On my corporate box
/usr/include
wasn't available. So I put this portable simple solution (if you have Python) into my init files. You can torture it into a one-liner if you wish:Tried
and seen what comes back?
There's no standard utility to do this. I believe your best bet is to write such a utility yourself. Use strerror() to print the associated error message.