dark

Check if a NFS share is mounted

blank

Below is a small Perl example how to check for NFS mounted shares on a Linux host.
The script does not need any specific modules, and makes use of the /etc/mtab file.

#!/usr/bin/perl
use strict; use warnings;

my @mount_points = do {local @ARGV = '/etc/mtab'; <>};
foreach my $mnt (@mount_points){
    next unless $mnt =~ /nfs/;
    my ($node, $mnt_point, $fs, $options, $dump, $fsck) = split /\s+/, $mnt;
    print "Found NFS share $node mounted on $mnt_point\n";
}
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Previous Post

Changing file permissions in Perl

Next Post

Backup to free Hetzner FTP

Related Posts