19-6
User Guide for Resource Manager Essentials 4.1
OL-11714-01
Chapter 19 CLI Utilities
CWCLI
$req->content($str);
my $res = $ua->request ($req);
my $result;
if ($res->is_error)
{
print "ERROR : ", $res->code, " : ", $res->message, "\n"; $result = '';
}
else {
$result = $res->content;
if($result =~ /Authorization error/)
{ print "Authorization error\n";
}
else {
print $result ;
}
}
}
Setting CWCLIFILE Environment Variable
You can store your username and password in a file and set a variable CWCLIFILE which points to the file,
if you want to avoid the -p argument which will reveal the password in clear text in CLI.
You should maintain this file and control access permissions to prevent unauthorized access.
If CWCLIFILE is set only to filename instead of full path, cwcli framework looks for the current working
directory.
If you use the -p argument, even after setting the CWCLIFILE variable, the password is taken from the
command line instead of CWCLIFILE. This is not secure and usage of this argument is not recommended.
The password must be provided in the file in the following format:
username password
Where username and password are the CiscoWorks login credentials. The delimiter between the
username and password is a single space.
You must enter a comma as the delimiter if the password is blank. Otherwise, cwcli framework will fail
to validate the password.
Example to run the cwcli command with the CWCLIFILE file:
On Windows, at the command prompt enter:
C:\Program Files\CSCOpx\bin>set CWCLIFILE=D:\ciscoworks\password.txt
C:\Program Files\CSCOpx\bin>cwcli export changeaudit -u admin -view
"/RME@ciscoworksservername/Normal Devices"
Where the file, password.txt contains the username and password for CiscoWorks server.