HP P6000 Replication Solutions Manager CLI Reference (T3680-96071, June 2012)

sub usage {
print "\n\n\***********************************************************************\n\n";
print "Use: clui_socket_config_retrieval.pl <host><port><username><password><command>\n\n";
print " host - ip or name\n";
print " port - the port the clui is on\n";
print " username - admin user name\n";
print " password - admin password\n";
print " command - The command to send to the server (in quotes)\n\n";
print "*************************************************************************\n";
} # end sub usage
Sample SSL client using Perl
# a test client for testing CLUI Result Code Retrieval
#
use strict;
use IO::Socket::SSL;
my ($hostname, $line, $passwd, $username, $res, $sock, $port, $cmd);
if(@ARGV < 5){
usage();
die "\nincorrect number of arguments\n\n";
}
$hostname = $ARGV[0];
$port = $ARGV[1];
$username = $ARGV[2];
$passwd = $ARGV[3];
$cmd = $ARGV[4];
if(!($sock = IO::Socket::SSL->new( PeerAddr => $hostname,
PeerPort => $port,
Proto => 'tcp',
SSL_use_cert => 0,
))) {
warn "unable to create socket: ", &IO::Socket::SSL::errstr, \n";
exit(1);
}
print $sock "LOGIN USERNAME=$username PASSWORD=$passwd\r\n";
#read login handshake and discard
readResponse();
print $sock "sel sys LA";
readResponse();
print $sock "sel man cueball";
readResponse();
#Send command passed in via arg
$sock->print($cmd . "\r\n");
print("debug");
$line = readResponse();
print("$line\n");
#close our socket
$sock->close();
#exit success if we make it here
exit 0;
#sub to find the </commandresponse> string that is found
#after setting result type to xml
sub readResponse {
my $resp = "";
my $line = "";
$line = "";
while(index($resp, "</commandresponse") < 0){
$line = readline $sock;
$resp = $resp . $line;
50 User-written client examples