I received a file from a friend (a really fantastic perl programmer) for checking disc space usage of web sites on a server.
I continuously slam him with a barrage of questions……. So I am trying rather unsuccessfully to find my own answers now.
The script should check for disc space usage in sites which I place directories for under the
my @sites= list on line 14.
This all looks pretty simple to me and I believe I understand it……. Except on thing. The reason it doesn’t work seems to be line 8
“if ($pass ne 'Tn9SG0s') { exit; }”
I understand that the code says if you receive a pass not equal to
'Tn9SG0s' then exit. But what I don’t understand is what is 'Tn9SG0s'?
Right now the script prints line 2 and exits. Any thoughts or ideas would be most appreciated. THANKS!
Here it is enlighten me please!
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
use CGI;
my $query = new CGI;
my $pass = $query->param('pass');
if ($pass ne 'Tn9SG0s') { exit; }
$path = "/home/httpd/$site/html/";
use File::Find;
my @sites = ("xyz-site/xyz-site-directory",
"xyz-site2/xyz-site-directory2"
);
push(@sites, '/home/tomato/',
#put any other directories in here
);
foreach my $site (@sites) {
$sizeb = 0;
$path = "/home/httpd/$site" if $site !~ m!^/!;
$path = "$site" if $site =~ m!^/!;
#$path = "/home/stanley/";
$file = 0;
&find ( sub { $sizeb += -s }, "$path");
&find ( sub { $file += 1 }, "$path");
my $sizekb = int ($sizeb / 1024);
my $sizemb = int ($sizekb / 1024);
print qq(<h4> $site </h4>);
print " Files $file <br>";
print " bytes $sizeb <br>";
print "Kbytes $sizekb <br>";
print " mbytes $sizemb <br>";
}
PS I have tried to comment out line line 6
my $pass = $query->param('pass'); but then the script just hangs.... So what is wrong with my new CGI (line 5).
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.