05-06-2011 07:05 AM
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.
05-06-2011 01:45 PM
Did you set the DCRCLIFILE correctly, or use the tip in this thread: https://supportforums.cisco.com/message/658677?
05-09-2011 12:31 AM
The code does the following:
$ENV{'DCRCLIFILE'} = "
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...
05-09-2011 01:34 PM
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.
05-10-2011 12:07 AM
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
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...
05-10-2011 07:16 AM
You could try:
my $res = `dcrcli -u admin cmd=exp fn=export.csv ft=CSV 2>NUL`;
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide