- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell error with addition
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 03:45 AM
10-08-2003 03:45 AM
# typeset -Z2 numero=7
# echo $numero
07
# (( numero = $numero + 1 ))
# echo $numero
08
# (( numero = $numero + 1 ))
sh: 08 + 1 : The specified number is not valid for this command.
Is there a patch for this bug ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 04:03 AM
10-08-2003 04:03 AM
Re: Shell error with addition
This has to be due to the -Z.
Try it with -i2 - that defines it as an integer & speeds the math to boot.
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 04:10 AM
10-08-2003 04:10 AM
Re: Shell error with addition
I don't that it is even oficailly recognized as a bug: a numeric string preceded with 0 is interpreted as octal notation. You probaly have to change your variable definition to something like
typeset -i numero=7
and then perform other operations in order to write it with a zero in front.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 04:16 AM
10-08-2003 04:16 AM
Re: Shell error with addition
The -Z right justifies & pads the value with leading zeros if the first nonblank char is a digit. The pad depends on the n value - in this case 2.
So the 7 is padded to 07.
BUT - I don't *think* it's stored as an integer & I think that's what is causing the "message".
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 04:23 AM
10-08-2003 04:23 AM
Re: Shell error with addition
you are probably right. I just thought that the system was protesting against doing an addition to what it considered being the highest octal number.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 07:02 PM
10-08-2003 07:02 PM
Re: Shell error with addition
If my parameter is to be considered as an octal value, it can't be 8 (or 08). And "07 + 1" would give 10.
With HP-UX 10.20, i don't have this result.
I get :
# typeset -Z2 string=7
# (( string = $string + 1 ))
# echo $string
08
# (( string = $string + 1 ))
# echo $string
09
Which is OK !!
With HP-UX 11.11, i can solve my problem in using two parameters ,one as a string[Z2] and one as an integer. But i don't think it is a normal behaviour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 07:11 PM
10-08-2003 07:11 PM
SolutionI still think the problem is related to the system perceiving "08" as an octal value.
And although I do not like to disagree with Pharaohs I think the problem fits the description for patch PHCO_29699, which holds a reference to patch PHCO_26789:
http://www4.itrc.hp.com/service/cki/patchDocDisplay.do?patchId=PHCO_29699
Please see the "Defect description" and the error message.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 07:36 PM
10-08-2003 07:36 PM
Re: Shell error with addition
YES ! I understand now. So i was wrong, and it is a normal behaviour. And the Pharoahs are still the Pharoahs !
Since HP-UX 11 accepts ISOC standards... and not HP-UX 10.20.
(( 07 + 1 )) is calculated as an octal value, but the result is put in a string parameter as a decimal value, so i get 08. And (( 08 + 1 )) is impossible as an octal operation.
CQFD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 08:33 PM
10-08-2003 08:33 PM
Re: Shell error with addition
If for whatever reasons you do not install the patch, one workaround is to strip the 0 prefix e.g.:
numero=`echo $numero | sed 's/^0//'`
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 08:59 PM
10-08-2003 08:59 PM
Re: Shell error with addition
if you read the description of the patch, it says that a parameter with a leading 0 is interpreted as an octal number IF you INSTALL this patch.
And i don't need the 'sed' tool for a workaround :
numero=${numero##*0}