check for error number

September 1st, 2006 mysurface Posted in Developer, echo, perror | Hits: 21185 | No Comments »

Error or no success running a command always return a number, usually it will return 0 unless it occurs an error. To check what error number it returns, do this after command is done.

echo $?

To test this, simply ls something doesn’t exist, then it will return value 2. Sometimes, you can obtain the error number, and you want to know what is the number indicate, you can do this

perror 2

it will shows

OS error code   2:  No such file or directory

perror command come with mysql-server, if you do not install mysql-server, you won’t have this command.

Leave a Reply