-2
我试图从网页上运行服务器上的Python脚本,我决定使用PHP来执行它。从我从线上的教程中读到的内容,它应该很简单,只要工作,但是无论何时我尝试使用PHP提交表单,我都会得到以下错误代码。PHP - 从PHP执行Python
Parse error: syntax error, unexpected T_STRING in /home/dertyui/public_html/root/wwwdustin/rss/sm/runpython.php on line 6
不完全确定我做错了什么,代码是如此之短我预计它只是工作。我做了一定要仔细检查安全模式是关闭我的服务器上,并有文件权限设置为755。这里是我的其他代码:
提交表单页面(index.html的)
<html>
<head>
</head>
<body>
<form action="runpython.php" method="post">
Status: <input type="text" name="status" />
<input type="submit" />
</form>
</body
</html>
RunPython。 php(运行Python脚本)
<?php
$commandtorun = '/usr/bin/python2.7 /home/dertyui/python/scripts/socialmedia/StatusPoster.py --accountname dustin --statusupdate ' . $_POST["status"] . '--statusupdatelink http://google.ca'
exec($commandtorun);
?>
解析错误是非常具有描述性的 – Don 2012-08-07 20:56:02
除了@ Lusitanian的回答,你可能想在--statusupdatelink之前放一个空格 – Samuel 2012-08-07 20:56:35