- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- math error under 11.23 (perceived as octal?)
Operating System - Linux
1753569
Members
5731
Online
108796
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО01-18-2006 09:29 AM
тАО01-18-2006 09:29 AM
I have the following code the works under 11.11 (using /usr/bin/sh):
TODAYS_JULIAN_DATE=$(date +%j) (this yields '018' today)
This statement then executes OK:
((whatever=$TODAYS_JULIAN_DATE-$LAST_LOGIN_JULIAN_DATE))
This resolves to: (( whatever=018-16 ))
However, under 11.23 the previous statement gives the following error message:
sh: 018-16 : The specified number is not valid for this command
I'm guessing the shell sees '018' as an octal number, rather than a decimal number. (Not sure if that's a valid guess).
Any ideas on what I could do so this script works under both 11.11 and 11.23?
TIA,
Scott
TODAYS_JULIAN_DATE=$(date +%j) (this yields '018' today)
This statement then executes OK:
((whatever=$TODAYS_JULIAN_DATE-$LAST_LOGIN_JULIAN_DATE))
This resolves to: (( whatever=018-16 ))
However, under 11.23 the previous statement gives the following error message:
sh: 018-16 : The specified number is not valid for this command
I'm guessing the shell sees '018' as an octal number, rather than a decimal number. (Not sure if that's a valid guess).
Any ideas on what I could do so this script works under both 11.11 and 11.23?
TIA,
Scott
Solved! Go to Solution.
- Tags:
- octal
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-18-2006 09:41 AM
тАО01-18-2006 09:41 AM
Solution
Use typeset to declare your variable types. Do a 'man sh-posix' and search for typeset for more information.
typeset -i TODAYS_JULIAN_DATE
typeset -i LAST_LOGIN_JULIAN_DATE
TODAYS_JULIAN_DATE=$(date +%j)
LAST_LOGIN_JULIAN_DATE=$(whatever you use to get 16)
((whatever=$TODAYS_JULIAN_DATE-$LAST_LOGIN_JULIAN_DATE))
echo ${whatever}
typeset -i TODAYS_JULIAN_DATE
typeset -i LAST_LOGIN_JULIAN_DATE
TODAYS_JULIAN_DATE=$(date +%j)
LAST_LOGIN_JULIAN_DATE=$(whatever you use to get 16)
((whatever=$TODAYS_JULIAN_DATE-$LAST_LOGIN_JULIAN_DATE))
echo ${whatever}
- Tags:
- typeset
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 03:31 AM
тАО01-19-2006 03:31 AM
Re: math error under 11.23 (perceived as octal?)
Patrick -
That works great! Thanks for the help!
(This is probably the 10th-12th time I've had to make a script change moving from 11.11 to 11.23. Whatever happened to backwards compatibility? AAARRRRGGGGGHHHH!)
Scott
That works great! Thanks for the help!
(This is probably the 10th-12th time I've had to make a script change moving from 11.11 to 11.23. Whatever happened to backwards compatibility? AAARRRRGGGGGHHHH!)
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2006 04:13 AM
тАО01-19-2006 04:13 AM
Re: math error under 11.23 (perceived as octal?)
Patrick's solution solved my problem.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP