我正在用php创建一个网页,如果按下一个按钮,php脚本将使用
shell_exec()
命令。python脚本使用fpdf python库创建pdf文件。当我从command shell运行相同的脚本时,它工作得很好,但是当我尝试从php运行python脚本时,它什么也没有给我。以下是php代码:
<!doctype html>
<?php
$command = escapeshellcmd('/home/amogh/server/test.py');
$output = shell_exec($command);
echo $output;
?>
python脚本:
#! /usr/bin/python
#print ('hello')
from fpdf import FPDF
fp = open('downloads/boot.txt', 'r')
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', '', 11)
line = fp.read()
pdf.multi_cell(200, 5, line, 0, 1)
pdf.output('test.pdf', 'F')
还有,我在用
lighttpd
服务器。有人能告诉我哪里出错了吗?