DSD
08-07-2006, 04:34 PM
My VPS was upgraded, and now my custom script doesn't seem to work. Here's the script:
<?php
// Maximum acceptable daily transfer, in MB:
$trigger = 10000;
// Your email address:
$mail_to = "mycell@messaging.sprintpcs.com";
$today = `/usr/bin/vnstat -s | grep today`;
$parts = explode("/",$today);
$total = trim($parts[2]);
$t_parts = explode(" ",$total);
$totalnum = trim($t_parts[0]);
if (stristr($totalnum,",")) { $totalnum = str_replace(",","",$totalnum); }
if ($totalnum > $trigger) {
$mail_subj = " Excessive bandwidth usage?";
$mail_msg = "Today's VPS bandwidth usage has reached $total\n\n";
$mail_msg .= "(triggered at $trigger MB.)";
mail($mail_to, $mail_subj, $mail_msg, "From: $mail_to");
}
?>
~
and here is what I get at the command prompt
root@norway [/]# ./checkbw
./checkbw: line 1: ?php: No such file or directory
./checkbw: line 2: //: is a directory
./checkbw: line 3: =: command not found
./checkbw: line 4: //: is a directory
./checkbw: line 5: =: command not found
./checkbw: line 7: =: command not found
./checkbw: line 8: syntax error near unexpected token `('
./checkbw: line 8: `$parts = explode("/",$today);'
I'm trying to run it as root, and I've played with the permissions, they seem to do no good. My other php sites are fine
Any ideas?
<?php
// Maximum acceptable daily transfer, in MB:
$trigger = 10000;
// Your email address:
$mail_to = "mycell@messaging.sprintpcs.com";
$today = `/usr/bin/vnstat -s | grep today`;
$parts = explode("/",$today);
$total = trim($parts[2]);
$t_parts = explode(" ",$total);
$totalnum = trim($t_parts[0]);
if (stristr($totalnum,",")) { $totalnum = str_replace(",","",$totalnum); }
if ($totalnum > $trigger) {
$mail_subj = " Excessive bandwidth usage?";
$mail_msg = "Today's VPS bandwidth usage has reached $total\n\n";
$mail_msg .= "(triggered at $trigger MB.)";
mail($mail_to, $mail_subj, $mail_msg, "From: $mail_to");
}
?>
~
and here is what I get at the command prompt
root@norway [/]# ./checkbw
./checkbw: line 1: ?php: No such file or directory
./checkbw: line 2: //: is a directory
./checkbw: line 3: =: command not found
./checkbw: line 4: //: is a directory
./checkbw: line 5: =: command not found
./checkbw: line 7: =: command not found
./checkbw: line 8: syntax error near unexpected token `('
./checkbw: line 8: `$parts = explode("/",$today);'
I'm trying to run it as root, and I've played with the permissions, they seem to do no good. My other php sites are fine
Any ideas?
