简体   繁体   English

PHP 执行 bash 脚本给出错误“语法错误:新行意外”

[英]PHP executing bash script gives error “Syntax error: newline unexpected”

I use a PHP page to execute a command and in the errorlog of apache I see the following line, every time the command is executed by the php page.我使用 PHP 页面执行命令,并在 apache 的错误日志中看到以下行,每次命令由 php 页面执行时。 When I execute the command in terminal everything is working fine.当我在终端中执行命令时,一切正常。

sh: 2: Syntax error: newline unexpected

Here is the php:这是 php:

exec("/usr/bin/phantomjs some-params);

And here is the script /usr/bin/phantomjs :这是脚本/usr/bin/phantomjs

#!/bin/sh
LD_LIBRARY_PATH="/usr/lib/phantomjs:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
exec "/usr/lib/phantomjs/phantomjs" "$@"

I am unable to find where the problem is.我无法找到问题所在。 I also tried with shell_exec , but it gives the same error.我也尝试过shell_exec ,但它给出了同样的错误。 Can somebody see where it is or give me some guidance?有人可以看到它在哪里或给我一些指导吗?

For other people with the same issue: The html/string parameter must be enclosed with 'single quotes'.对于其他有相同问题的人: html/string 参数必须用“单引号”括起来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM