Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Check if NFS Filesystem is mounted

Posted on 1998-11-23
4
Medium Priority
?
1,450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 300 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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.…
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…
Six Sigma Control Plans

715 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