Having to support many different UNIX platforms is a challenge and a pain in the same time. What commands should I run on each of them for a trivial checkup ? What are the options should I use ? etc. So I came up with a script for the abstraction purposes, where the only think I need is the hostname and the <thing> to check. Because originally this was spin around the FS usage I wrote for this functionality. Now I think it may be expanded to something more generic, but till then I wild like to share it, cause - I find it cool to use.
#!/usr/bin/perl -w # # df Act like UNIX df utility # usage: run df.pl and follow the text # use Net::Ping; use Net::OpenSSH; use IO::Socket; my ($ssh, $rsh) = qw(22 514); while (1) { print "nom du serveur: "; chomp(my $server = <STDIN>); die "le nom du serveur est obligatoire\n" unless $server; print "nom du FS sans le premier / : "; chomp(my $fs = <STDIN>); die "le nom du FS est obligatoire\n" unless $fs; sub os_port { foreach (@_) { $sock = new IO::Socket::INET(PeerAddr => $server, PeerPort => $_, Proto => 'tcp'); last if $sock; } $sock; } my $p = Net::Ping->new; #new("icmp") if ($p->ping($server)) { my $sock = os_port($ssh, $rsh); die "Aucune possibilite a se connecte au serveur\n" unless $so +ck; while (<$sock>) { $sock_string = $_; last; } close $sock; } $p->close(); if ($sock_string) { my $openssh = Net::OpenSSH->new($server); $openssh->error and die "Couldn't establish SSH connection: ". $openssh->error +; chomp(my $uname = $openssh->capture("uname -s")); $openssh->error and die "remote uname command failed: " . $openssh->err +or; if ($uname =~ /Linux/) { $openssh->system("df -h /$fs") or die "remote command failed: " . $openssh->error; } elsif ($uname =~ /AIX/) { $openssh->system("df -m /$fs") or die "remote command failed: " . $openssh->error; } elsif ($uname =~ /HP-UX/) { $openssh->system("bdf /$fs") or die "remote command failed: " . $openssh->error; } else { $openssh->system("df /$fs") or die "remote command failed: " . $openssh->error; } } else { system "rsh $server bdf /$fs"; } }
Here it is - AIX, HP-UX and Linux platforms via SSH or Rlogin connections acting as expected in each and every case.

In reply to Let's do it transparently by rustic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.