HP StorageWorks Replication Solutions Manager Command Line User Interface Reference (T3687-96029, August 2005)

sub readResponse {
my $resp = "";
$line = "";
while((index($line,">")<0) and (index($line,"Thank you for using")<0) ){
$line = $telnet->get;
$resp = $resp . $line;
}
return $resp;
}
sub stripLine{
$telnet->getline;
}
sub usage {
print "\n\n\*************************************************************************\n\n";
print "Use: clui_telnet_sample.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 via the clui - in quotes\n\n";
print "*************************************************************************\n";
} # end sub usage
Sample Socket cl
ient using Perl
#Copyright: Copyright (c) 2003
#Company: Hewlett-Packard Company
use strict;
use IO::Socket;
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];
#may want to jump timeout if slow connection or remote server
# blocks for longer than timeout val when zipping server files
$sock = new IO::Socket::INET (
PeerAddr $hostname,
Proto => 'tcp',
Timeout => 60
);
die "Could not create socket: $!\n" unless $sock;
print $sock "LOGIN USERNAME=$username PASSWORD=$passwd\r\n";
#read the telnet login handshake and disgard
readResponse();
#Send command passed in via arg
46
User-written client