- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep > file in ksh script and set-e
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
Discussions
Discussions
Discussions
Forums
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
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
тАО02-01-2002 05:02 AM
тАО02-01-2002 05:02 AM
It looks like this :
set -e
..
grep -i licens /tmp/licmessages > /tmp/licwarns
..
set +e
The script needs to scan the 'licmessages' file for the word 'licens'. If the word 'licence' doesn't occur. The script execution stops (because of the set -e statement). All scripts on the application use this set-e and set+e statements for avoiding job scripts from hanging.
Eliminating the set-e,set+e statements doesn't force the script to quit when an error occurs. The job executes nicely the rest of the statements. However, this is not the standard way of using the application.
How can I catch the error in the the grep statement and still use the set-e,set+e statements ?
Thanks
Franky
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2002 05:11 AM
тАО02-01-2002 05:11 AM
Re: grep > file in ksh script and set-e
RETURN VALUE
Upon completion, grep returns one of the following values:
0 One or more matches found.
1 No match found.
2 Syntax error or inaccessible file (even if matches were
found).
____
Grep will usualy return a not 0 value. You can not use set +e while using grep.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2002 05:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2002 05:19 AM
тАО02-01-2002 05:19 AM
Re: grep > file in ksh script and set-e
How about something like this:
-----------------------------
#!/bin/sh
####################
# Lic Check
# How many
count=`cat /tmp/licmessages | grep licen | wc -l`
# Show result
echo $count
# Use the result to do somthing
if [ $count != 0 ]
then
echo "More than zero"
fi
---------------------------------
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2002 05:27 AM
тАО02-01-2002 05:27 AM
Re: grep > file in ksh script and set-e
I used Steves solution.
It worked !
Regards,
Franky