blob: 548b92657f0d267c712b8f48db449b75723b227a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/usr/bin/perl
use lib qw(.. /usr/lib/libDrakX);
use network::smb;
use network::nfs;
"@ARGV" =~ /-h/ and die "usage: lsnetdrake [-h] [--nfs] [--smb]\n";
my $nfs = !@ARGV || "@ARGV" =~ /-(nfs)/;
my $smb = !@ARGV || "@ARGV" =~ /-(smb)/;
$| = 1;
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
if ($nfs) {
my @servers = network::nfs::find_servers();
foreach my $server (sort_names(@servers)) {
my $server_name = $server->{name} || $server->{ip};
foreach (sort_names(network::nfs::find_exports($server))) {
print "$server_name:$_->{name}", $_->{comment} && " ($_->{comment})", "\n";
}
}
}
if ($smb) {
my @servers = network::smb::find_servers();
foreach my $server (sort_names(@servers)) {
my $server_name = $server->{name} || $server->{ip};
foreach (sort_names(network::smb::find_exports($server))) {
print "//$server_name/$_->{name}", $_->{comment} && " ($_->{comment})", "\n";
}
}
}
sub sort_names {
sort { $a->{name} cmp $b->{name} } @_;
}
|