#!/usr/bin/perl use strict; use warnings; sub trim($); sub ltrim($); sub rtrim($); my $pduserid; my $pdpasswd; my @webseal_svrs; my $numWebsealSvrs; my $websealsvr; my @websealsvr_info; my $junk; my $host; my $port; my $hostln; my $portln; if (@ARGV == 2) { $pduserid = $ARGV[0]; $pdpasswd = $ARGV[1]; @webseal_svrs = `pdadmin -a $pduserid -p $pdpasswd server list | grep webseald | sort`; $numWebsealSvrs = @webseal_svrs; if ($numWebsealSvrs > 0) { print("There are $numWebsealSvrs WebSEAL servers reported for this TAM installation.\n\n"); foreach $websealsvr (@webseal_svrs) { chomp($websealsvr); @websealsvr_info = `pdadmin -a $pduserid -p $pdpasswd server show $websealsvr`; $hostln = $websealsvr_info[2]; $portln = $websealsvr_info[4]; ($junk, $host) = split(/:/, $hostln); ($junk, $port) = split(/:/, $portln); $host = trim($host); $port = trim($port); print("[".trim($websealsvr)."] "); `nc -w 2 -v -z $host $port`; } } else { print("There are no configured WebSEAL servers being reported by TAM.\n"); } } else { print("This script requires two parameters - TAM id and TAM passsword, for example:\n"); print("perl pd_list_websealsvrs.pl sec_master password\n"); } # trim functions from www.somacon.com/p114.php # Perl trim function to remove whitespace from the start and end of the string sub trim($) { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; return $string; } # Left trim function to remove leading whitespace sub ltrim($) { my $string = shift; $string =~ s/^\s+//; return $string; } # Right trim function to remove trailing whitespace sub rtrim($) { my $string = shift; $string =~ s/\s+$//; return $string; }