Solved

Check if NFS Filesystem is mounted

Posted on 1998-11-23
4
1,416 Views
Last Modified: 2008-03-04
I have an NT Share that is NFS exported and being mounted on an AIX 4.2.1 system. Before I write anything to that mounted NFS volume, I want to make sure that it is in fact mounted otherwise I want to error out. How can I check if the filesystem is mounted?

Angel
0
Comment
Question by:aleyva
  • 2
  • 2
4 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 1206519
open (FID , "df -k |") || die "df failed: !$";
@text = <FID>;
foreach (@text) { print "$_" if m/^hostname/;}

0
 

Author Comment

by:aleyva
ID: 1206520
I tried working with your sparse response, but couldn't make it work. Before I reject the answer, can you explain how to use your information. If I do a `df -k` with the filesystem unmounted, I get the listing for the filesystem that the mount point is created on, if the system is mounted, then I get the information for the NFS filesystem. How can I tell the difference without simply looking for key words like:

/dev/images_staging     2097152   1985636    6%      444     1% /images_staging
parsas001:d:\agtout    39596000   7281912   82%       70     1% /images_staging/outgoing/PAR

Angel
0
 

Author Comment

by:aleyva
ID: 1206521
I think I got it now.

Thanx
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206522
> If I do a `df -k` with the filesystem unmounted, I get the listing for the filesystem that the mount point is on

NO, when it is not mounted, df doesn't list it.
But you may have a mounted filesystem which is not available, UNIX calls this a
"stale NFS handle"; in this case df will list it, but usually hangs at this point :-(

If my answer was to short, probably following is more what you like:
   open (FID , "df -k |") || die "df failed: !$";
   @text = <FID>;
   close FID;
   foreach (@text) { if (m/^hostname:/ {$is_mounted=1; last;} }
and there are a couple of ways to write it  in perl ..

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how do I grep for a specfic DNS record in a directory 3 35
perl script 4 94
cpan issue 1 55
Perl Sort Question 4 118
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now