I had a really strange error on my cgi app.
I also found a solution.. and it makes about as much sense to me as my ex girlfriend..
It deals with Time::Format 1.09
A certain time format string actually crashes my cgi with no mercy- with silence to STDERR or STDOUT (yes, i'm tailing the logfile, etc etc etc ..) - but called via regular cli, it causes no problems.
In my CGI app, I had a crash recently that I tracked down to this:
However this works swell:my $last_login = 1231357784; my $ll = Time::Format::time_format( 'Weekday Month dth yyyy, h:mm', $l +ast_login ); print STDERR "We should get here\n"; # but we dont
my $last_login = 1231357784; my $ll = Time::Format::time_format( 'mm/dd/yy hh:mm', $last_login ); print STDERR "We should get here\n"; # and we do
I thought maybe I had a messed up time format string.. But I had been using this Time::Format string for a while.. so.. Just for curiosity.. I wrote this cgi, a simple script with no crazy deps, none of my other code etc.. just a real sanity check here..
#!/usr/bin/perl -w use strict; use CGI; use Time::Format; my $last_login = 1231357784; my $c = new CGI; print $c->header; #my $a = Time::Format::time_format( 'mm/dd/yy hh:mm', $last_login ); # + time format string i see working fine my $a = Time::Format::time_format( 'Weekday Month dth yyyy, h:mm', $la +st_login ); # time format string that crashes print "last login $a";
Which, guess what... crashes.
However - If I run from the command line...
root@thalidomide# perl /var/www/cgi-bin/script.cgi Content-Type: text/html; charset=ISO-8859-1 last login Wednesday January 7th 2009, 14:49
So I changed it around to use the other string 'mm/dd/yy hh:mm' and it works again via cgi.. ... WTF??
As well as via obviously, cli.. works fine and outputs
root@thalidomide# perl /var/www/cgi-bin/script.cgi Content-Type: text/html; charset=ISO-8859-1 last login 01/07/09 14:49
(I should have noted that this error did not happen on all servers, some worked fine. This is in regards to a failing server.. )
From man Time::Format: Time::Format_XS is optional but will make C<%time> and C<time_format> much faster. The version of Time::Format_XS installed must match the version of Time::Format installed; otherwise Time::Format will not use it (and will issue a warning).
I didn't get a warning. I got the silent treatment. (Much like my ex girlfriend when she left me.. (it'll take a coder to find a pattern here))
So.. on the server that crashes (via cgi, no servers crash on cli).
Time::Format_XS 1.02
Time::Format 1.09
Thus.. cpan Time::Format_XS .. we *have* the most current version.
Thus.. I look on the working server.. what is the version of Time::Format and Time::Format_XS there? Same Time::Format.. Missing Time::Format_XS.
Go back to the server crashing via cgi.. locate Format_XS.pm .. rm it, voila. Works fine, without using BEGIN { $Time::Format::NOXS=1; }.
Still unresolved .. why did it always work via cli? Why only on one time format string but not another??? Very interesting.
Thanks to Charles Hamilton for solving that. Perlbotics, for figuring out a solution in the first place and where to look!
In reply to Time::Format string that works in cli crashes cgi by leocharre
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |