- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell script condition statement
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
06-16-2005 02:18 PM
06-16-2005 02:18 PM
"if [ $BACKUP_RC -eq 0 ] then"
How do I incorporate an OR into it, syntax-wise?
Thanks much,
Damian
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 02:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 03:01 PM
06-16-2005 03:01 PM
Re: Shell script condition statement
you can use logical operators say e.g
if [ $BACKUP_RC -eq 0 || $BACKUP -eq 1 ] then ...
try this
Cheers !!!
eknath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 04:49 PM
06-16-2005 04:49 PM
Re: Shell script condition statement
if [[ ${BACKUP_RC} -eq 0 || ${BACKUP_RC} -eq 4 ]]
then
statments;
fi
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 05:56 PM
06-16-2005 05:56 PM
Re: Shell script condition statement
= += -= *= /= %= ^= assignment
?: conditional expression
|| logical or
& & logical and
~ !~ regular expression match, negated match
< < = > > = != == relationals
blank string concatenation
+ - add, subtract
* / % multiply, divide, modulus
+ - ! unary plus, unary minus, logical negation
^ exponentional
++ -- increment, decrement
$ field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 06:47 PM
06-16-2005 06:47 PM
Re: Shell script condition statement
if you only expect 0 or 4 you already have good answers. However, it is good practice to double quote variables in order to avoid syntax errors in case a variable is not expanded.
If you expect a wider diversity of return values, you could use a case statement, e.g.:
case "$BACKUP_RC" in
0) echo the returncode was 0;;
1) echo the returncode was 1;;
4) echo the returncode was 4;;
*) echo the returncode was completely unexpected;;
esac
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 07:13 PM
06-16-2005 07:13 PM
Re: Shell script condition statement
Another possibility is the shell built-in "case". That is faster (because it's a shell built-in) and more readeble.
The syntax would look like:
case ${BACKUP_RC} in
0)
echo "BACKUP_RC is 0"
;;
1)
echo "BACKUP_RC is 1"
;;
*
echo "BACKUP_RC is ${BACKUP_RC}"
;;
esac
Hope that helps!
Cheers,
Renarios
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 01:16 AM
06-17-2005 01:16 AM
Re: Shell script condition statement
echo " do something "
fi