exec() not exec-ing?
| From: | gilrain | Date: | Sat, 04 Jan 2003 06:20:33 +0000 |
| Subject: | exec() not exec-ing? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-130208@lists.php.net to get a copy of this message | ||
Hi folks,
On previous (good) advice given in my "Timeout during SMTP operation."
thread, I've offloaded some work in my function to an external Python
script. The script works beautifully when I execute it myself, from the
shell, but I can't get my PHP script to execute it for me. My new function
is:
// Sends e-mail to the specified list of member e-mail addresses.
function ncSendMail($addresses, $subject, $body)
{
// Delete last mailing file.
$ftp = ftp_connect("ftp.somewhere.net");
ftp_login($ftp, "someone", "something");
ftp_delete($ftp, "www/ncmail/mailing.txt");
ftp_quit($ftp);
// Create new mailing file.
$mailing =
fopen("ftp://someone:something@ftp.somewhere.net/www/ncmail/mailing.txt",
"w");
// Get the automail 'footer' from the 'automail' table and append it to
the body.
$body .= ncGetAutomail("footer");
// Load addresses, comma seperated and terminated by a newline, into the
mailing file.
foreach($addresses as $address)
{
$string .= $address.",";
}
$string = substr($string, 0, strlen($string)-1); // Strip last comma.
fwrite($mailing, $string."\n");
// Write subject, then body, seperated by newlines, into the mailing
file.
fwrite($mailing, $subject."\n");
fwrite($mailing, $body);
// Close file, call script in background, return.
fclose($mailing);
exec("python ncMailer.py >/dev/null &");
return true;
}
The mailing file is written fine, and the Python script parses the file and
e-mails fine, as long as I run it myself from the shell. However, the exec()
call appears to do nothing at all, least of all run my script. I've tried a
number of different things, but nothing seems to work.
Any help would be greatly appreciated,
gilrain