I have a file that looks like this:
992535783 6 6 7 19
992536692 9 6 9 24
992537600 8 8 7 23
992538508 7 10 6 23
992539415 5 15 8 28
992540322 8 14 8 30
992541229 7 15 10 32
992542137 7 13 10 30
992542984 6 16 8 30
992543891 8 12 6 26
Which is epoch time followed by user's logged into three
different rooms, followed by the total. I use this code to
read it in and display it in pretty html:
#!/usr/bin/perl -w
use strict;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
my @headings = ('Time','MC3004','MC3005','MC3027');
my @rows = th(\@headings);
open LABS, "/software/polaris-mfcf/data/local/w.stat" or die "Unable t
+o open file: $!\n";
for (<LABS>)
{
my ($time,$num4,$num5,$num7) = split;
$time = localtime($time);
my $check = substr(localtime(time),4,6);
push @rows, td([$time,$num4,$num5,$num7]) if $time =~ /$check/
+;
}
close LABS;
print header;
print start_html('Polaris Usage');
print table({-border=>undef},
caption(strong('Polaris Terminal Usage')),
Tr(\@rows)
);
print end_html;
When I run it gives a file not found error from the die command.
But, the file does exist. I've tried running it from a
different user's web space with a copy of the file and it works
fine. When I run it from the command line, it runs fine.
When I run it from the command line and pipe the output to a
file, that file contains all the right/vaild html and output.
Does anyone know why, when I try to access the file from it's
own directory it would be unable to find a file that exists?
FouRPlaY
Learning Perl or Going To die() Trying
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.