Solved

Check if NFS Filesystem is mounted

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Six Sigma Control Plans

627 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