November 2013
Intermediate to advanced
224 pages
6h 9m
English
Every time a process finishes, it has the opportunity to return a single number to the process that called it. This is referred to as its exit code or exit status. A status of zero indicates that the program succeeded in what it was asked to do. Any other value indicates there was some sort of problem and that the command failed in some way. The shell variable $? allows us to examine the exit code of any app we run. We can use this to verify that mysqldump, the command our database backup app uses to perform the actual backup, exits zero on success and nonzero otherwise, like so:
| | $ mysqldump non_existent_database |
| | No such database 'non_existent_database' |
| | $ echo $? |
| | 1 |
| | $ |
Read now
Unlock full access