- Community Home
- >
- Storage
- >
- Entry Storage Systems
- >
- Disk Enclosures
- >
- Re: HP P2000 CLI perl scripting error
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2011 07:18 AM
05-20-2011 07:18 AM
I am trying to write a perl script using HP P2000 CLI library to create snapshots and map the snapped volume to host before nightly backup and delete the snapshots after the backup is complete.
I refered HP P2000 CLI reference guide to script this functionality.
http://bizsupport1.austin.hp.com/bc/docs/support/SupportManual/c02520779/c02520779.pdf
(page: 14 & 15)
I installed perl software locally in my desktop.
I used below script to connect to storage system and trying to execute "Show configuration" cli command to start with. When i execute the below script. I am getting the "command timed-out at line login.pl in 35". Can any one help out to resolve this?
Perl script: login.pl
---------------------
use Net::Telnet;
sub cLogin {
$telnet->open($_[0]);
$telnet->waitfor(/(login|username)[: ]*$/i);
$telnet->print("$_[1]");
$telnet->waitfor(/password[: ]*$/i);
$telnet->print("$_[2]");
# either got a login or a prompt
@ok = $telnet->waitfor(/(#|login:*) /i);
if ($debug_commands == 1) { print "-"; print @ok; print "-\n"; }
if ($ok[1] =~ m/login/gi)
{
return 0;
}
else
{
return 1;
}
}
$ipAddr = $ARGV[0];
$username = $ARGV[1];
$password = $ARGV[2];
$telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die');
if ( !cLogin('000.000.00.0000','johnsmith','smithpass') == 1 )
{
print("Error: $username user failed to log in. Exiting.\n");
$telnet->close;
exit(0);
}else{
print("Info: Login successfull.\n");
@test = $telnet->cmd("show configuration");
print @test;
for ($i=0; $i
print ("@test[ $i ]");
}
}
Output
------
C:\Perl\eg>perl login.pl
Info: Login successfull.
command timed-out at login.pl line 32
Thanks in advance,
Viswa
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2011 01:36 AM
05-24-2011 01:36 AM
Solutioni faced exactly the same problem. But i think i found a solution. You have to throw away the hole script and define the Prompt.
1.) HP thinks too complicated... :-)
2.) try this:
use Net::Telnet;
$TARGET_IP = $ARGV[0];
$USER = $ARGV[1];
$PASSWORD = $ARGV[2];
$telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die',Prompt => '/\# $/i');
$telnet->open($TARGET_IP);
$telnet->login($USER, $PASSWORD);
print $telnet->cmd('show configuration');
For me this works.
cu
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2011 05:33 AM
05-24-2011 05:33 AM
Re: HP P2000 CLI perl scripting error
Your code simple and easy. Thanks for your response.
After a try we got this below to work as well.
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die',Prompt => '/\# $/i');
$return = 0;
@chkLgn = cLogin("150.123.70.172", "MLC_Admin", "metapass");
if ( !chkLgn == 1 )
{
print("Error: $username user failed to log in. Exiting.\n");
$telnet->close;
exit(0);
} else {
executeCmd("show volumes");
$telnet->close;
exit($return);
}
sub cLogin {
$telnet->open($_[0]);
$telnet->waitfor('/(login|username)[: ]*$/i');
$telnet->print("$_[1]");
$telnet->waitfor('/password[: ]*$/i');
$telnet->print("$_[2]");
# either got a login or a prompt
@ok = $telnet->waitfor('/(#|login:*) /i');
if ($debug_commands == 1) {
print "-";
print @ok;
print "-\n";
}
if ($ok[1] =~ m/login/gi)
{
return 0;
}
else
{
return 1;
}
}
sub executeCmd {
@sV = $telnet->cmd("$_[0]");
for ($i=0; $i
if("@sV[ $i ]" !~ /Error/){
print ("@sV[ $i ]");
} else {
$return = 1;
}
}
}
Thanks Again
-Viswa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2012 03:26 PM
11-14-2012 03:26 PM
Re: HP P2000 CLI perl scripting error
anybody have any SSH script to the SAN storage I can use? I tried expect,openssh and nothing work, kept getting
this error when I use a command like "show vdisks"
Received disconnect from ipaddress: 2: unsupported command
- Tags:
- ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2012 03:36 PM
11-14-2012 03:36 PM
Re: HP P2000 CLI perl scripting error
btw I can't use Telnet, our IT guys disable telnet.