Cisco Systems 4.1 Dust Collector User Manual


 
12-94
User Guide for Resource Manager Essentials 4.1
OL-11714-01
Chapter 12 Managing Software Images Using Software Management
Understanding User-supplied Scripts
Sample Script
The sample script illustrates how to use this option before the upgrade to see if the device is accessible
and after the upgrade to see whether it was successful.
The sample.bat file contains:
c:\progra~1\cscopx\bin\perl c:\progra~1\cscopx\files\scripts\swim\samplescript.pl
The samplescript.pl file contains:
#!/usr/bin/perl
BEGIN
{
use lib "$ENV{NMSROOT}/objects/perl5/lib/Net";
}
use Net::Telnet;
#my $output="";
## The following Environment variables are not passed on by Software Image Management
## Need to set these variables for the script to work as expected
$ENV{'Path'}="C:\\PROGRA~1\\CSCOpx\\MDC\\tomcat\\bin;C:\\PROGRA~1\\CSCOpx\\MDC\\Apache;C:\\PROGRA~1\\CSCOpx\\
MDC\\jre\\bin;C:\\PROGRA~1\\CSCOpx\\MDC\\bin;C:\\PROGRA~1\\CSCOpx\\lib\\jre\\bin\\server;C:\\PROGRA~1\\CSCOpx
\\objects\\db\\win32;C:\\PROGRA~1\\CSCOpx\\bin;c:\\cscopx\\lib\\jre\\bin\\server;c:\\cscopx\\lib\\jre141\\bin
\\server;C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem;C:\\Program Files\\Common Files\\Adaptec
Shared\\System;c:\\progra~1\\cscopx;c:\\progra~1\\cscopx\\bin;";
$ENV{'TEMP'}=$ENV{'TMPDIR'};
$ENV{'TMP'}=$ENV{'TMPDIR'};
$ENV{'SystemRoot'}="C:\\WINNT";
###### Required Environment variables are set #########
my $prmptchar = '/\>/i';
$filename = $ENV{'CRM_DEV_NAME'} . '.txt';
if ($ENV{'CRM_SCRIPT_CONTEXT'} eq 'PRE-DOWNLOAD') {
open OUTFILE, "> $filename" or die "Can't open file";
print OUTFILE %ENV;
my $host = $ENV{'CRM_DEV_MGMT_IP_ADDR'};
my $pwd = $ENV{'CRM_PRIMARY_PASSWORD'};
print OUTFILE $host;
print OUTFILE $pwd;
$telnet = new Net::Telnet(Input_Log=>"inp.txt");
$prev = $telnet->host($host);
print OUTFILE $prev;
print OUTFILE "Conntecting to Host....";
$telnet->open($host);
print OUTFILE "Connected ...";
$telnet->dump_log("dmp.txt");
$telnet->waitfor('/Username: $/i');
$telnet->print($ENV{'CRM_PRIMARY_USERNAME'});
$telnet->waitfor('/Password: $/i');
$telnet->print($pwd);
print OUTFILE "Password send";
($output) = $telnet->waitfor('/#$/i');
print OUTFILE "Returned after waitfor";
print OUTFILE $output;
CRM_ENABLE_PASSWORD Enable password.
CRM_PRIMARY_USERNAME Primary user name configured on the device.
CRM_PRIMARY_PASSWORD Primary password configured on the device.
CRM_DEV_MGMT_IP_ADDR IP address provided in Device and Credential Repository for management.
Variable Description