Solved

Check if NFS Filesystem is mounted

Posted on 1998-11-23
4
1,427 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need Helping Editing Perl Script for PowerChute Network Shutdown 3 83
Any syntax error for this clone.plscript 6 139
Perl modules on linux ec2 3 104
create a gui in perl 3 87
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 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