LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-17-2014, 04:31 AM   #1
Dave Rove
LQ Newbie
 
Registered: Oct 2014
Posts: 3

Rep: Reputation: Disabled
How do I look up bash exit codes?


I'm having difficulty locating a comprehensive up-to-date list of error codes from Bash. e.g.:

$ udevadm info /dev/sdx; echo Exit code $?
Unknown device, --name=, --path=, or absolute path in /dev/ or /sys expected.
Exit code 4


How is one supposed to look up such exit codes?
 
Old 10-17-2014, 04:42 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,527

Rep: Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439
that is not the exit code of bash, but the command executed (in your case udevadm). The best place to start is the man page of that command.
 
1 members found this post helpful.
Old 10-17-2014, 04:49 AM   #3
Dave Rove
LQ Newbie
 
Registered: Oct 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
I see. Nothing there. So that command is improperly documented?
 
Old 10-17-2014, 05:34 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Sadly, that's pretty normal; you'd have to check the src code if you really want to know.

The main thing to know is that (in *nix) there is an unwritten (AFAICR) convention that 0 (zero) means success, any other value is an issue; some times just a warning, sometimes a failure.

If writing code wrappers, then if a cmd exit code != 0, log it and exit the current process and/or try to handle it gracefully.
I'm afraid its just one of those things you learn by experience.


NB: non-zero values mean different things for each cmd; zero is the only 'common' one.

HTH
 
1 members found this post helpful.
Old 10-17-2014, 06:22 AM   #5
Dave Rove
LQ Newbie
 
Registered: Oct 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
OK. Thanks all.
 
Old 10-17-2014, 06:59 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,527

Rep: Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439
actually udevadm not only exited with exit code 4 but printed an error message: unknown device. So that is the cause of that exit code.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Exit codes svlay Linux - Newbie 2 10-09-2013 06:13 PM
[SOLVED] Determining exit codes for unrar (or alternative) in Bash Fishbowler Linux - Software 5 09-19-2012 08:54 AM
[SOLVED] Bash Shell Script Exit Codes metallica1973 Programming 4 01-25-2012 12:14 PM
Bash scripting problem with exit codes Jeiku Programming 2 05-15-2006 02:22 AM
exit codes introuble Programming 2 05-08-2005 01:53 PM


All times are GMT -5. The time now is 08:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration