...

View Full Version : emailing results from php page using cron job



BTbuses
07-09-2007, 09:50 AM
following on from a previous thread about automatically sending a page, i have setup a cronjob, yet nothing wants to send except error messages. I scrapped the original idea of having a report sent in pdf format to everyone in a mailing list to just having the report sent to me in what ever format (html or whatever)

i have this page http://btoti.com/fleet-allocation-generate.php of which at a particular time & date, I want the results (as shown by link) to be sent to my email address.

For the latest cronjob that I made, i inputed the date/time into the relevant fields, then put public_html/fleet-allocation-generate.php as the command, and got back this:


public_html/fleet-allocation-generate.php: line 1: html: No such file or directory
public_html/fleet-allocation-generate.php: line 2: head: No such file or directory
public_html/fleet-allocation-generate.php: line 3: meta: No such file or directory
public_html/fleet-allocation-generate.php: line 4: title: No such file or directory
public_html/fleet-allocation-generate.php: line 5:
: command not found
public_html/fleet-allocation-generate.php: line 6: link: No such file or directory
public_html/fleet-allocation-generate.php: line 7: link: No such file or directory
public_html/fleet-allocation-generate.php: line 8:
: command not found
public_html/fleet-allocation-generate.php: line 9: base: No such file or directory
public_html/fleet-allocation-generate.php: line 10: /head: No such file or directory
public_html/fleet-allocation-generate.php: line 11:
: command not found
public_html/fleet-allocation-generate.php: line 12: h1: No such file or directory
public_html/fleet-allocation-generate.php: line 13:
: command not found
public_html/fleet-allocation-generate.php: line 14: ?php: No such file or directory
public_html/fleet-allocation-generate.php: line 15:
: command not found
<p>report produced on
public_html/fleet-allocation-generate.php: line 16:
: command not found
public_html/fleet-allocation-generate.php: line 17: syntax error near unexpected token `('
public_html/fleet-allocation-generate.php: line 17: `echo gmdate("l, F j, Y @ g:i a", time()+(36000));


And after trying many google searches on what I should be doing, I am completely lost!
So any ideas guys/gals?

StupidRalph
07-09-2007, 10:52 AM
So what does that page do? Does it email you that information or just output it for the browser. Try posting that code up.

You need to have that page perform some type of action. Outputting it to the browser only helps if you're debugging the script (IMO).

BTbuses
07-09-2007, 11:10 AM
ah ok, there is plenty of code on the script that says to pull information from a flatfile and retrieve the necessary criteria and display

the link posted originally is the results, of which i want the cronjob to automatically send to me.

code for fleet-allocation-generate.php is:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Brisbane Transport Buses</title>

<link rel="stylesheet" type="text/css" href="btb-style.css" media="all">
<link rel="stylesheet" type="text/css" href="btb-styleprint.css" media="print">

<base href="http://www.brisbanetransport.info/">
</head>

<h1>Bus Fleet Allocation</h1>

<?php

echo "<p>report produced on ";
echo gmdate("l, F j, Y @ g:i a", time()+(36000));

$fData = file('data/fleet.txt');
$fp=fopen("data/depots.txt","r");
$loop=0;
while (!feof($fp))
{$data = fgets($fp, 4096);
$value=explode ("|",trim($data));
if ($value[2]<>"S" and $value[0]<>"code" and $value[0]<>"")
{$fDepot[$loop]=$value[0];
$fDepot2[$loop]=$value[1];
$fDepot3[$loop]=$value[2];
$loop=$loop+1;}
}
fclose ($fp);
$fp=fopen("data/fleetspecs.txt","r");$loop=0;while (!feof($fp)){$data = fgets($fp, 4096);$value=explode ("|",trim($data));$fChassis[$loop]=$value[0];$fChassis2[$loop]=$value[1];$loop=$loop+1;} fclose ($fp);
$loop=1;
while ($loop<count($fData))
{list($bus,$chassisbody,$vin,$bodyno,$delivered,$withdrawn,$depot,$rego,$active,$AC,$WC,$updated) = explode("|", $fData[$loop]);
if ($withdrawn<>"x")
{$counts[$depot][$chassisbody]=$counts[$depot][$chassisbody]+1;
$store[$depot][$chassisbody]=$store[$depot][$chassisbody]." ".$bus;
if ($AC=="Y" and $active=="Y") {$totac[$depot]=$totac[$depot]+1;
$grtotac=$grtotac+1;}
if ($WC=="Y" and $active=="Y") {$totwc[$depot]=$totwc[$depot]+1;
$grtotwc=$grtotwc+1;}
}
$loop=$loop+1;
}

echo "
<p>
<table id='main' border='1' style='border-collapse: collapse' bordercolor='#000000'>
<tr><th>Body/Chassis</th>
";

$loop=0;
while ($loop<count($fDepot))
{if ( $fDepot3[$loop]<>"O") echo "<th>$fDepot[$loop]</th>";
$loop=$loop+1;}
echo "<th>Other</th><th>Total</th></tr>";
$loop=1;
while ($loop<count($fChassis2))
{$loop2=0;
$xtotal=0;
$ototal=0;
while ($loop2<count($fDepot))
{$xtotal=$xtotal+$counts[$fDepot[$loop2]][$fChassis[$loop]];
$loop2=$loop2+1;}
if ($xtotal<>0)
{echo "<tr><td valign='top'><a href='fleet-details.php?search=$fChassis[$loop]'>$fChassis2[$loop]</td>";
$loop2=0;
while ($loop2<count($fDepot))
{if ( $fDepot3[$loop2]<>"O")
{echo "<td align='center'>".$counts[$fDepot[$loop2]][$fChassis[$loop]]."</td>";
$deptotal[$loop2]=$deptotal[$loop2]+$counts[$fDepot[$loop2]][$fChassis[$loop]];}
else $ototal=$ototal+$counts[$fDepot[$loop2]][$fChassis[$loop]];
$loop2=$loop2+1;}
echo "<td align='center'>";
if ($ototal <>0) echo $ototal;
echo "</td><td align='center'><b>$xtotal</b></td></tr>";
$othtotal=$othtotal+$ototal;
$gxtotal=$gxtotal+$xtotal;
}
$loop=$loop+1;}
echo "<tr><td valign='top'>Total of buses allocated to depot</td>";
$loop2=0;
while ($loop2<count($fDepot))
{if ( $fDepot3[$loop2]<>"O") {echo "<td align='center'><b>";
if ($deptotal[$loop2] <> 0) echo $deptotal[$loop2] ;
echo "</b></td>";}
$loop2=$loop2+1;}
echo "<td align='center'><b>$othtotal</b></td><td align='center'><b>$gxtotal</b></td></tr>";
echo "<tr><td valign='top'>Total of air-conditioned buses</td>";
$loop2=0;
while ($loop2<count($fDepot))
{if ($fDepot3[$loop2]<>"O") {echo "<td align='center'><b>".$totac[$fDepot[$loop2]]."</b><br>";
if ($deptotal[$loop2] <>0) echo round(100*$totac[$fDepot[$loop2]]/$deptotal[$loop2],2)."%";
echo "</td>";}
else $othac=$othac+$totac[$fDepot[$loop2]];
$loop2=$loop2+1;}
echo "<td align='center'><b>$othac</b><br>".round(100*$othac/$othtotal,2)."%</td><td align='center'><b>$grtotac</b><br>".round(100*$grtotac/$gxtotal,2)."%</td></tr>";
echo "<tr><td valign='top'>Total of accessible buses</td>";
$loop2=0;
while ($loop2<count($fDepot))
{if ($fDepot3[$loop2]<>"O")
{echo "<td align=center><b>".$totwc[$fDepot[$loop2]]."</b><br>";
if ($deptotal[$loop2] <>0) echo round(100*$totwc[$fDepot[$loop2]]/$deptotal[$loop2],2)."%";
echo "</td>";}
else $othwc=$othwc+$totwc[$fDepot[$loop2]];
$loop2=$loop2+1;}
echo "<td align='center'><b>$othwc</b><br>".round(100*$othwc/$othtotal,2)."%</td><td align='center'><b>$grtotwc</b><br>".round(100*$grtotwc/$gxtotal,2)."%</td></tr>";
echo "
</table><p>
<hr size=1px style='color: #000000'>
";
$loop=0;
while ($loop<count($fDepot))
{$loop2=0;
$depottotal=0;
while ($loop2<count($fChassis))
{
$depottotal=$depottotal+$counts[$fDepot[$loop]][$fChassis[$loop2]];
$chassistots[$loop2]=$chassistots[$loop2]+$counts[$fDepot[$loop]][$fChassis[$loop2]];
$loop2=$loop2+1;}
if ($depottotal<>0)
{echo "<div class='pagestart'>";
echo "<p>Depot: <b>$fDepot2[$loop]</b></p><blockquote>";
$loop2=0;
while ($loop2<count($fChassis))
{if ($counts[$fDepot[$loop]][$fChassis[$loop2]]<>0)
{echo "<u>$fChassis2[$loop2]</u><br>";
echo $store[$fDepot[$loop]][$fChassis[$loop2]]."<br>";
echo "Total: ".$counts[$fDepot[$loop]][$fChassis[$loop2]]." <hr size=1px style='color: #000000'>";}
$loop2=$loop2+1;
}
echo "
Total of buses allocated to $fDepot2[$loop]: $depottotal</p></blockquote><hr size=1px style='color: #000000'>
";
$grtotal=$grtotal+$depottotal;
}
$loop=$loop+1;

}
?>

</body>

</html>


so somehow, need to get the the final output as shown sent to me on the time basis that I setup in the cron

Cheers



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum