- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Verifying an NFS mount is available in a scrip...
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
12-24-2007 10:01 AM
12-24-2007 10:01 AM
Verifying an NFS mount is available in a script
I am writing a script that contains a section that verifies an NFS mount is available in order for the script to continue. The first two commands that I have are the following:
bdf |grep tools
if { ${RC} -eq 0]
I would like to have the script do the following: If the above NFS mount is available, the script can continue. If the remote mount is not available, I would like the script to record the error condition in a log file, and stop execution.
What syntax can I use to accomplish this? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2007 10:33 AM
12-24-2007 10:33 AM
Re: Verifying an NFS mount is available in a script
RC=$?
echo $RC
if [ $RC -eq 0 ]
then
echo successful
else
echo not successful
exit
fi
should work in bourne, posix, bash, ksh...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2007 10:34 AM
12-24-2007 10:34 AM
Re: Verifying an NFS mount is available in a script
bdf | grep tools > /dev/null
RC=$?
echo $RC
if [ $RC -eq 0 ]
then
echo successful
else
echo not successful >> yourlogfile
exit
fi
should work in bourne, posix, bash, ksh...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2007 10:42 AM
12-24-2007 10:42 AM
Re: Verifying an NFS mount is available in a script
Your script could do something like this:
#!/usr/bin/sh
typeset MNT=/tools
typeset LOG=/var/tmp/`basename $0`.log
bdf | grep -q " ${MNT}$" || \
{ echo "$(date '+%x %X') No mountpoint: ${MNT}" >> ${LOG}; exit 1; }
echo "Mountpoint ${MNT} available -- continuing"
...
The LOG file is named with the basename of your script and written into '/var/tmp'. The (q)uiet form of 'grep returns only the exit status which if not zero results in a log entry with a timestamp and the name of the mountpoint that was missing. Note that the 'grep' is anchored to the end of a line with the $-character and has a space before the defined name. This means that you can match and differentiate '/tools', from '/tools2', for example.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2007 08:58 PM
12-24-2007 08:58 PM
Re: Verifying an NFS mount is available in a script
Instead of grep, why not do the bdf on the file system in question?
As in JRF's:
bdf ${MNT} || \
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2007 11:17 PM
12-24-2007 11:17 PM
Re: Verifying an NFS mount is available in a script
bdf ${MNT} > /dev/null 2>> ${LOG} || \
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2007 02:23 AM
12-25-2007 02:23 AM
Re: Verifying an NFS mount is available in a script
If you still want to use grep on the mounted File systems and not running BDF on a specific mount, I allways prefer to grep in the /etc/mnttab file since the BDF has some output issues ( devides the output to more than one line sometimes ) and it runs faster.
By the way can anyone think of a reason why the grep in /etc/mnttab may give a different result than the bdf ( I mean an issue where mnttab thinks FS is mounted but it is accutaly not or something like that) ?
Leonid.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2007 07:01 AM
12-25-2007 07:01 AM
Re: Verifying an NFS mount is available in a script
As "man mnttab" says, "/etc/mnttab should
never be manually edited", but I've seen it
done. Normally, it's pretty safe, however.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2007 07:41 AM
12-25-2007 07:41 AM
Re: Verifying an NFS mount is available in a script
If the NFS mount fails bdf will hang, making the script output of little use because you won't get anything.
I would use a combination of showmount -e hostname (it can be localhost) and a /etc/fstab or the /etc/mnttab file to confirm that NFS mounts are valid.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com