#!/usr/bin/perl use Getopt::Long; use Pod::Usage; use Carp; use POSIX qw/strftime/; use Data::Dumper; use strict; #Export NA Library use Opsware::NAS::Client; #Declare Login Variables my($user,$pass,$host) = ('someuser', 'somepwd', 'somehost'); my $dttm = strftime('%Y:%m:%d:00:00:00',localtime); my $Diag_Date = $dttm; #Options GetOptions( "user=s" => \$user, "pass=s" => \$pass, "host=s" => \$host, 'help|h|?' => \my $help) or pod2usage(2); pod2usage(1) if $help; # open a CLI session my $nas = Opsware::NAS::Client->new(); my $res = $nas->login(-user => $user, -pass => $pass, -host => $host); #Handling login errors unless ($res->ok()) { printf STDERR ("*** error: %s\n", $res->error_message()); printf STDERR ("Did you supply valid Credentials?\n"); printf STDERR ("Please verify User/Password.\n"); exit(1); } my @listoftasks=("getSwitches","getFirewalls"); foreach my $specificTask (@listoftasks) { my $tasklist = $nas ->list_task( start => $Diag_Date, name => $specificTask, type => "Run Command Script" ); print Dumper($tasklist); }; $nas->logout(); # clean up undef $nas; #Inform Status print "\n\n\rStatus: Done!\n\n"; exit(0);