- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting Question
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-2002 11:51 AM
03-01-2002 11:51 AM
I am executing java command line arguments to check the status of processes in a korn shell script:
example:
java.com.abcdedf check API
The output on stdout is:
API1 RUNNING
API2 RUNNING
API3 RUNNING
API4 PAUSE
.....
I run this in cron every 10 mins and it pages the SAs when the status is other than RUNNING.. One of the APIs let's say API4 goes into a PAUSE status very often and I would like to modify the script to not to email the SA's the first time it goes into PAUSE status but the second time.
Right now everything goes in a file like this
java.... check API > $FILE
grep -v RUNNING $FILE > $FILE2
I later check if this file is more than some value then page with the output ...
Any help will be appreciated..
I am not sure If I was clear enough...
Thanks,
Shabu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2002 12:08 PM
03-01-2002 12:08 PM
Re: Scripting Question
One simple solution would be to leverage the count option ('-c') of 'grep' to test if there are more than one instance of your target:
if [ `grep -c "API14 PAUSE" /tmp/file` -gtr 1 ]
then
echo "more than one match"
else
echo "only one match"
fi
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2002 12:12 PM
03-01-2002 12:12 PM
Re: Scripting Question
then
grep -v RUNNING $FILE | grep -v PAUSE > $FILE2
else
grep -v RUNNING $FILE > $FILE2
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2002 12:17 PM
03-01-2002 12:17 PM
Re: Scripting Question
He'd be better off setting a counter when he sees a pause & resetting it when pause disappears - don't you think?
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2002 01:54 PM
03-01-2002 01:54 PM
Re: Scripting Question
Hi JRF, as Jeff pointed out I am not appending the file ...but I get the idea now...
For now, temporarily I will write to two files and then validate..
If you guys could think about a permanent and efficient way to check this that will be great..
I would like to keep this simple (not too many variables/files)..
Thanks again !
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2002 02:07 PM
03-01-2002 02:07 PM
Solution#!/sbin/sh
if grep PAUSE /tmp/javaoutput >/dev/null 2>&1
then
if [ -e /tmp/PAUSED_ONCE ]
then
echo "this is the 2nd match, paging out now ..."
rm -f /tmp/PAUSED_ONCE
else
echo "this is only the 1st match"
touch /tmp/PAUSED_ONCE
fi
fi
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2002 02:37 PM
03-01-2002 02:37 PM
Re: Scripting Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2002 03:40 PM
03-01-2002 03:40 PM
Re: Scripting Question
Thanks Steven !
Nice logic :-) I tweaked it a little bit to not to satisfy the first condition if run from the command prompt and also exported variables instead of touch/rm files. Hope that's okay.
-Shabu