cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
947
Views
5
Helpful
5
Replies

dcrcli command line options

Sean Gilkes
Level 1
Level 1

Hi all,

     I'm using the dcrcli common services command line utility as part of a Perl script which is being called as part of a cgi script.  The problem I am facing is that the dcrcli utility keeps producing messages like "<dcrcli> * Password file found using DCRCLIFILE environment variable." on standard out, and I cannot find a way of shutting it off.  This is causing the Apache server to stop the script with this message:

[Fri Apr 29 13:47:40 2011] [error] [client xxx.xxx.xxx.xxx] malformed header from script. Bad header=Exporting Devices...: PerformChange.pl, referer: https://cw-server/cgi-bin/Script.pl
[Fri Apr 29 13:47:42 2011] [error] [client xxx.xxx.xxx.xxx] <dcrcli> * Password file found using DCRCLIFILE environment variable.\r, referer: https://cw-server/cgi-bin/Script.pl

H.E.L.P.

5 Replies 5

yjdabear
VIP Alumni
VIP Alumni

Did you set the DCRCLIFILE correctly, or use the tip in this thread: https://supportforums.cisco.com/message/658677?

The code does the following:

$ENV{'DCRCLIFILE'} = "\\dcrclifile.txt";

system("dcrcli -u admin cmd=exp -expCred fn=$infile ft=CSV") == 0 || die "Creation of CiscoWorks export file failed: $?";

$ENV{'DCRCLIFILE'} = "";

The file is accessible (both the dcrclifile.txt and the output filename specified in dcrcli command line), because the output file is created.  The message logged in Apache's error.log file:

"malformed header from script. Bad header=Exporting Devices...:"

Shows that the dcrcli command is running: the part "Exporting Devices..." is the output message from dcrcli...

The malformed header error? That could be fixed as simply as adding "print header();" or "print "Content-type: text/html\n\n";" to the script.

My issue is with the DCRCLI command: I don't want to see any output from its execution!  For example, consider this simple script and its output.

The script:

#!/usr/local/bin/perl -w
#

use strict;

$ENV{'DCRCLIFILE'} = "dcrclifile.txt";
my $res = `dcrcli -u admin cmd=exp fn=export.csv ft=CSV`;

print("Result=$res\n");
$ENV{'DCRCLIFILE'} = "";

The outupt:

C:>perl test.pl

* Password file found using DCRCLIFILE environment variable.
Result=Exporting Devices...
Devices exported successfully to the file D:\Temp\DCRExport.csv

The line before "Result=" I can't seem to redirect.  I certainly would not want the output from this command messing up a carefully aligned web page, so putting a HTML content type before the command is executed is not an option...  I guess this is more of a Perl question rather than a cli question, because I don't think you can switch off these messages; I would just like to know if anyone knows how to redirect them...

You could try:

my $res = `dcrcli -u admin cmd=exp fn=export.csv ft=CSV 2>NUL`;
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: