Hello all,

Having some problem with PHP from the command line.

I have some code that grabs the input being sent to it with standard in and then processes it and stores it... when I run the file from the command line using the following command ...
# echo "test data" | php file.php
.. then it works fine, however i'm trying to get the file to pick up email... so I have set up a linux alias, the alias is...
test: "|php /home/test.php" me@email.com
The alias sends the mail to the me@email.com address however the php file does not seem to be accessed.. the php file logs data to a log file as soon as it opens, and this is not happening when sending email... so all works fine from command line but doesnt pick up email being sent to the alias..

the php code:
PHP Code:
#!/usr/bin/php
<?php
// this function will write to log.log some error details 
  
function write_log($mesaj)
  { 
    
$handle fopen("log.log","a");
    
fwrite($handle,date("Y-m-d h:i:s").": ".$mesaj."\n");
    
fclose($handle);
  }
  
write_log("start mailer ...");
// read the mail that is forwarded to the script ***
  
$fd fopen("php://stdin""r");
  
write_log("read mail");
  
$email "";
  while (!
feof($fd)) {
    
$email .= fread($fd1024);
  }
  
fclose($fd);
 
write_log("mail read");
// handle email ***
  
$lines explode("\n"$email);

  
// empty vars
  
$from "";
  
$date "";
  
$subject "";
  
$message "";
  
$splittingheaders true;

  for (
$i=0$i<count($lines); $i++) {
    if (
$splittingheaders) {

        
// look out for special headers
        
if (preg_match("/^Subject: (.*)/"$lines[$i], $matches)) {
            
$subject $matches[1];
        }
        if (
preg_match("/^From: (.*)/"$lines[$i], $matches)) {
            if(
strpos($lines[$i],"<"))
            {
            
//the name exist too in from header
              
$data explode('<',$lines[$i]);
              
$from substr(trim($data[1]),0,-1);
            }
            else{
            
//only the mail
              
$from  $matches[1];
            }
        }
        if (
preg_match("/^Date: (.*)/"$lines[$i], $matches)) {
            
$date $matches[1];
        }
    } else {
        
// not a header, but message
        
$message .= $lines[$i]."\n";
    }

    if (
trim($lines[$i])=="") {
        
// empty line, header section has ended
        
$splittingheaders false;
    }
  }
   
write_log("processing complete");
  
write_log("opening connecting to DB");

... 
some other stuff
Does anyone have any experience here or ideas why the php file would not work from that alias?

Any info much apperciated,
Cheers all,
Sir P