- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- expr: Syntax Error
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
03-01-2007 10:09 PM
03-01-2007 10:09 PM
I use below commands in my script:
fic=$(basename $extent_full)
long=`expr length $fic`
lgext=`expr $long - 1`
ext=`expr substr $fic $lgext 2`
Is there something incorrect with syntax as the error is coming everytime:
expr: Syntax error
expr: Syntax error
expr: Syntax error
Thanks for your advice.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 10:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 10:24 PM
03-01-2007 10:24 PM
Re: expr: Syntax Error
Add some debugging commands like:
echo "/$fic/"
to display the contents of the variables.
The slashes are there to reveal any spaces before or after the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 11:25 PM
03-01-2007 11:25 PM
Re: expr: Syntax Error
fic=$(basename $extent_full)
long=`expr length "$fic"`
lgext=`expr "$long" - 1`
ext=`expr substr "$fic" "$lgext" 2`
echo "[$fic]"
echo "[$long]"
echo "[$lgext]"
echo "[$ext]"
Values are:
[]
[0]
[-1]
[]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 11:47 PM
03-01-2007 11:47 PM
Re: expr: Syntax Error
> I still get this error once rather than 3 times after modification:
Values are:
[]
[0]
[-1]
[]
...and that's exactly what you get if $extent_full is empty or undefined!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2007 12:03 AM
03-02-2007 12:03 AM
Re: expr: Syntax Error
are you shure, your expr command understand the extend (non standard) operators?
A standard conform solution very close to your attempt may be:
fic=$(basename $extent_full)
long=$(expr $fic : '.*')
lgext=$(expr $long - 2)
ext=$(expr $fic : '.\{'$lgext'\}\(.*\)')
If I read correctly, you want to get the last two characters of $extend_full. You can get that much easier; try one of these:
expr $extend_full : '.*\(..\)'
print $extend_full | sed 's/.*\(..)/\1/'
print $extend_full | awk '{print substr($0,length($0)-2)}'
or in Posix shell:
typeset -R2 str=$extend_full
print $str
mfG Peter