I am trying to fax out using sendfax but it wont work, when I echo my exec statement it works fine…what’s my execution issue?
$tmpfname = tempnam("/tmp", $_REQUEST['Email']);
$handle = fopen($tmpfname, "w");
fwrite($handle, $body);
fclose($handle);
exec('sendfax -n -d $to $tmpfname', $test2, $test3);
var_dump($test2);
echo $test3;
?>
and I get the response on the page as:
array(0) { } 255
Thanks for any help!
You’re using
'single quote strings'which do not have variable values interpolated. Try replacing:with:
Also, you must be certain that neither
$tonor$tmpfnamecontain any shell meta-characters. As it stands, an email address offoo;rm -rf /&@example.comwould probably delete some files you care about. (I think using$_REQUEST['Email']as part of a filename is a bad idea.)Be sure to read the notes at the PHP
exec()documentation page.