LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 02-23-2014, 02:34 AM   #1
mirage1993
Member
 
Registered: Feb 2014
Location: China
Distribution: CentOS6.4
Posts: 51

Rep: Reputation: Disabled
Question this script's returned value is 120,why??


I creat a file and edit it .

Code:
#!/bin/bash

exit 888
then,
Code:
[root@localhost]# ./script.sh 
[root@localhost]# echo $?
120
I want to know why the returned value is not 888,thanks.

Last edited by mirage1993; 02-23-2014 at 05:19 AM.
 
Old 02-23-2014, 03:47 AM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 343Reputation: 343Reputation: 343Reputation: 343
Hi there,

Quote:
Originally Posted by mirage1993 View Post
I creat a file and edit it .

Code:
#!/bin/bash

exit 888
then,
Code:
[root@localhost scripts]# ./script.sh 
[root@localhost scripts]# echo $?
120
I want to know why the returned value is not 888,thanks.
that's because return values are limited to 8 bits for historical reasons. So the given return value of 888 is truncated, the high-order bits are dropped:

Code:
  888 (dec) = 0x0378
 strip high byte and convert back:
  0x78 = 120 (dec)
There you go.

[X] Doc CPU
 
1 members found this post helpful.
Old 02-23-2014, 03:53 AM   #3
mirage1993
Member
 
Registered: Feb 2014
Location: China
Distribution: CentOS6.4
Posts: 51

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by Doc CPU View Post
Code:
  888 (dec) = 0x0378
 strip high byte and convert back:
  0x78 = 120 (dec)

great!!!thank you sooo much!!
@Doc CPU

Last edited by mirage1993; 02-23-2014 at 04:01 AM.
 
  


Reply

Tags
script, values


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
subprocess installed post-installation script returned error exit status 127 Kaind Ubuntu 3 11-15-2012 06:48 PM
E: hl1440lpr: subprocess installed post-removal script returned error exit status 126 5dana Linux - Hardware 2 06-11-2010 10:47 AM
difference between socket returned descriptor and accept returned descriptor naveenisback Programming 1 08-29-2009 04:55 AM
Cron appears to be messed up (E: cron: subprocess post-installation script returned e bujutsukai Linux - Newbie 1 07-24-2008 03:39 AM
shell script help: operating on files returned by find Ryzol Programming 4 06-12-2008 09:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:51 AM.

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