HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Want to include if statement in For loop.
Operating System - HP-UX
1833154
Members
2959
Online
110051
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
Forums
Discussions
Discussions
Discussions
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
11-08-2010 06:42 AM
11-08-2010 06:42 AM
Want to include if statement in For loop.
#This script monitors weblogic processes #8th Nov 2010
# /usr/local/bin/sh
. /usr/local/bin/oraenv_DVEC6FIN
Declare
SERVICE="DMADMIN TUXALSB_DOM TUXWLI_DOMA MASTER_LOCA QUEUEFRDCHE GETFRDRSLT SEMLINK"
echo "" > /tmp/Moni.log
for i in $SERVICE
do
# Check
K=`echo "psc" | tmadmin 2>/dev/null |grep -s $i |wc -l`
echo $i $K >> /tmp/Moni.log
done
While writing script.. some how Iam blocked. Pls help
I want to include "if statement" in between for loop statement like -
For DMADMIN Variable incase count is 0 then echo "Count for Domain Admin is 0" >> /tmp/Mon.log
Pls help in logic..
# /usr/local/bin/sh
. /usr/local/bin/oraenv_DVEC6FIN
Declare
SERVICE="DMADMIN TUXALSB_DOM TUXWLI_DOMA MASTER_LOCA QUEUEFRDCHE GETFRDRSLT SEMLINK"
echo "" > /tmp/Moni.log
for i in $SERVICE
do
# Check
K=`echo "psc" | tmadmin 2>/dev/null |grep -s $i |wc -l`
echo $i $K >> /tmp/Moni.log
done
While writing script.. some how Iam blocked. Pls help
I want to include "if statement" in between for loop statement like -
For DMADMIN Variable incase count is 0 then echo "Count for Domain Admin is 0" >> /tmp/Mon.log
Pls help in logic..
- Tags:
- for loop
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2010 07:26 AM
11-08-2010 07:26 AM
Re: Want to include if statement in For loop.
for i in $ADDRESS
do
count=0
if (( $count != 1 ))
then
echo $i
count++
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2010 08:07 AM
11-08-2010 08:07 AM
Re: Want to include if statement in For loop.
Hi:
#!/usr/bin/sh
SERVICE="DMADMIN TUXALSB_DOM TUXWLI_DOMA MASTER_LOCA QUEUEFRDCHE GETFRDRSLT SEMLINK"
LOG=/tmp/Moni.log
echo "" > ${LOG}
for i in ${SERVICE}
do
K=$(echo "psc" | tmadmin 2>/dev/null | grep -s -c ${i})
if [ "${K}" -eq 0 ]; then
echo "Count for $i is zero" >> ${LOG}
else
echo ${i} ${K}"
fi
done
...Notice that we eliminated the 'wc' since 'grep' can count as well as match. I also eliminated the use of the archaic backticks and replaced that with (...).
Regards!
...JRF...
#!/usr/bin/sh
SERVICE="DMADMIN TUXALSB_DOM TUXWLI_DOMA MASTER_LOCA QUEUEFRDCHE GETFRDRSLT SEMLINK"
LOG=/tmp/Moni.log
echo "" > ${LOG}
for i in ${SERVICE}
do
K=$(echo "psc" | tmadmin 2>/dev/null | grep -s -c ${i})
if [ "${K}" -eq 0 ]; then
echo "Count for $i is zero" >> ${LOG}
else
echo ${i} ${K}"
fi
done
...Notice that we eliminated the 'wc' since 'grep' can count as well as match. I also eliminated the use of the archaic backticks and replaced that with (...).
Regards!
...JRF...
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.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP