- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell script to email about nslookup failure
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
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
тАО06-10-2010 06:01 AM
тАО06-10-2010 06:01 AM
Shell script to email about nslookup failure
- Tags:
- nslookup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2010 06:33 AM
тАО06-10-2010 06:33 AM
Re: Shell script to email about nslookup failure
cat ./nsfailure
#!/usr/bin/sh
HOST=$1
RSLT=$(nslookup $1 | sed -ne "/can.t find/p")
[ -z "${RSLT}" ] || mailx -s "nslookup failed: ${RSLT}" root < /dev/null
exit
# ./nsfailure host_or_IP
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2010 06:53 AM
тАО06-10-2010 06:53 AM
Re: Shell script to email about nslookup failure
Oops, we need to capture STDERR, so:
# cat ./nsfailure
#!/usr/bin/sh
HOST=$1
RSLT=$(nslookup $1 2>&1 | sed -ne "/can.t find/p")
[ -z "${RSLT}" ] || mailx -s "nslookup failed: ${RSLT}" root < /dev/null
exit
# ./nsfailure host_or_IP
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2010 08:20 AM
тАО06-10-2010 08:20 AM
Re: Shell script to email about nslookup failure
Thanks so much for your help. I'm modifying the script at the moment and it will be ready to go by tomorrow.
I will let you know about the result.
Thanks so much again!
Best Regards,
Tharshini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2010 08:27 AM
тАО06-10-2010 08:27 AM
Re: Shell script to email about nslookup failure
Since you are new to this forum, welcome!
If/when you are satisfied with the answers you have received, please read:
http://forums.itrc.hp.com/service/forums/helptips.do?#28
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2010 11:32 PM
тАО06-10-2010 11:32 PM
Re: Shell script to email about nslookup failure
When I tried to run the script, it did not accept and gave this error continuously.
`RSLT=$' unexpected.
This is the script:
#!/bin/sh
cat /disk1r1/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora | cut -d= -f3 | grep -v 10 | grep -v 192 | grep -v ")" | sed 's/\(.*\)./\1/' >> output.txt
log="/apps/dba/bin/output.txt"; export log
rm log
for HOSTNAME in `more log`
do
RSLT=$(nslookup $HOSTNAME 2>&1 | sed -ne "/can.t find/p")
[ -z "${RSLT}" ] || mailx -s "nslookup failed: ${RSLT}" root < /dev/null
done
exit
Thanks for helping me out.
Best Regards,
Tharshini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2010 04:46 AM
тАО06-11-2010 04:46 AM
Re: Shell script to email about nslookup failure
> When I tried to run the script, it did not accept and gave this error continuously.
`RSLT=$' unexpected.
What shell are you running on what HP-UX release? '/bin/sh' should point to '/usr/bin/sh' which should be the POSIX shell.
The notation:
RSLT=$(nslookup ${HOST} 2>&1 | sed -ne '/can.t find/p')
...is a better (POSIX) form of the archaic back-ticks:
RSLT=`(nslookup ${HOST} 2>&1 | sed -ne '/can.t find/p'`
See if the back-tick syntax fixes your problem.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2010 04:53 AM
тАО06-11-2010 04:53 AM
Re: Shell script to email about nslookup failure
>for HOSTNAME in `more log`
You shouldn't be using more(1) here, that's for interactive use. Instead use:
for HOSTNAME in $(< log); do
>JRF: See if the back-tick syntax fixes your problem.
You left in a "(":
RSLT=`nslookup ${HOST} 2>&1 | sed -ne '/can.t find/p'`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2010 05:13 AM
тАО06-11-2010 05:13 AM
Re: Shell script to email about nslookup failure
> Dennis: You shouldn't be using more(1) here, that's for interactive use. Instead use:
for HOSTNAME in $(< log); do
If Tharshini is running a non-POSIX shell, I think that this too will be an issue. I would suggest the alternative:
for HOSTNANE in `cat log`; do
> Dennis > JRF: You left in a "(":
RSLT=`nslookup ${HOST} 2>&1 | sed -ne '/can.t find/p'`
Yes indeed I did. Thanks for catching that.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2010 05:19 AM
тАО06-11-2010 05:19 AM
Re: Shell script to email about nslookup failure
But Tharshini said: This is the script:
#!/bin/sh