HP iLO 4 Scripting and Command Line Guide

10 PERL scripting
Using PERL with the XML scripting interface
The scripting interface provided enables administrators to manage virtually every aspect of the
device in an automated fashion. Primarily, administrators use tools like HPQLOCFG to assist
deployment efforts. Administrators using a non-Windows client can use PERL scripts to send XML
scripts to the iLO devices. Administrators can also use PERL to perform more complex tasks than
HPQLOCFG can perform.
This section discusses how to use PERL scripting in conjunction with the Lights-Out XML scripting
language. PERL scripts require a valid user ID and password with appropriate privileges.
Download the sample scripts from the HP website at http://www.hp.com/go/ilo. Click iLO Sample
Scripts for Windowsor Lights-Out XML scripting sample for Linux on the Resources tab, under
Support.
XML enhancements
If you are using a utility other than HPQLOCFG (such as PERL), the following steps help ensure that
the iLO 4 firmware returns properly formatted XML. You must incorporate the following tag into
the script sent to iLO 4:
<LOCFG version="2.0">
You can place this tag in either the PERL script or the XML script. Placement of this tag is important.
If you place this tag in the PERL script, the tag must be sent after <?xml version="1.0"?> and
before the XML script is sent. If you place the tag in the XML script, the tag must be placed before
<RIBCL version="2.0">. If you are using the PERL script provided by HP, you can add the
bold line in the following example to return properly formatted XML syntax.
For example:
PERL script modification
# Open the SSL connection and the input file
my $client = new IO::Socket::SSL->new(PeerAddr => $host);
open(F, "<$file") || die "Can't open $file\n";
# Send the XML header and begin processing the file
print $client '<?xml version="1.0"?>' . "\r\n";
#Send tag to iLO firmware to insure properly formatted XML is returned.
print $client '<LOCFG version="2.0">' . "\r\n";
XML script modification
<!-- The bold line could be added for the return of properly
formatted XML. -->
<LOCFG version="2.0"/>
<RIBCL version="2.0">
<LOGIN USER_LOGIN="Adminname" PASSWORD = "password">
<!--Add XML script here-->
</LOGIN>
</RIBCL>
</LOCFG>
Opening an SSL connection
Perl scripts must open an SSL connection to the device HTTPS port, by default port 443.
Using PERL with the XML scripting interface 193