Subject: | Net::Cmd produces cybercrud in debug messages; doesn't allow message capture from rawdatasend |
My version of Net::CMD reports 2.29 - not in the selectbox here.
Net::Cmd prints GLOB{0x...} as the command name when debug is enabled.
This is really annoying as we often turn on debug to deal with user
issues, and explaining that this cybercrud is OK takes time.
Cause is that debug_print gets an object reference, but simply
stringifies it when writing to STDERR. It knows it's an object
reference, since it uses the ref to call debug_text.
Here is sample:
Net::SMTP=GLOB(0x2585e48)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x2585e48)<<< 250-PIPELINING
Net::SMTP=GLOB(0x2585e48)<<< 250-8BITMIME
Net::SMTP=GLOB(0x2585e48)<<< 250-SIZE 10000000
Net::SMTP=GLOB(0x2585e48)<<< 250-DSN
And here is the fix:
--- /usr/share/perl5/Net/Cmd.pm~ 2012-09-14 08:07:41.000000000 -
0400
+++ /usr/share/perl5/Net/Cmd.pm 2012-11-08 12:32:30.595254831 -0500
@@ -158,11 +158,12 @@
sub debug_text { $_[2] }
sub debug_print {
my ($cmd, $out, $text) = @_;
- print STDERR $cmd, ($out ? '>>> ' : '<<< '), $cmd->debug_text($out,
$text);
+ my $cmdName = ref( $cmd ) || $cmd;
+ print STDERR $cmdName, ($out ? ' >>> ' : ' <<< '), $cmd->debug_text
($out, $text);
}
Which produces:
Net::SMTP <<< 250-ENHANCEDSTATUSCODES
Net::SMTP <<< 250-PIPELINING
Net::SMTP <<< 250-8BITMIME
Net::SMTP <<< 250-SIZE 10000000
Net::SMTP <<< 250-DSN
Note that I added a space before the direction indicators; that seems
cleaner to me, but isn't essential.
Related issue: rawdatasend() doesn't call debug_print, or even
debug_text, but should to enable output capture without redirecting
STDERR.