Showing results for 
Search instead for 
Did you mean: 

dcrcli command line options

Sean Gilkes

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


5 Replies 5


Did you set the DCRCLIFILE correctly, or use the tip in this thread:

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: $?";


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`;


The outupt:


* 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...

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

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:

Recognize Your Peers