doulan7166 2019-06-10 17:37
浏览 279

如何使用php以正确的方式为shell_exec()提供参数

The following shell command will send mail from my Raspbbery:

mailnotify.sh "Test" "Dies ist eine Testnachricht."

enter image description here

Following try, starting this shell script using PHP will result to error:

/usr/local/bin/mailnotify.sh: 72: [: 1: unexpected operator

Why? How to pass parameters in correct way?

$parameter1="Test";
$parameter2="Dies ist eine Testnachricht.";
$parameter1=escapeshellarg($parameter1);
$parameter2=escapeshellarg($parameter2);
shell_exec("mailnotify.sh $parameter1 $parameter2");//won't run
shell_exec('mailnotify.sh "'.$parameter1.'" "'.$parameter2.'"');//won't run, too
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于PLUS模型中kapaa值的问题
    • ¥15 关于博途V17进行仿真时无法建立连接问题
    • ¥15 请问下这个红框里面是什么文档或者记事本编辑器
    • ¥15 机器学习教材中的例题询问
    • ¥15 求.net core 几款免费的pdf编辑器
    • ¥15 为什么安装HCL 和virtualbox之后没有找到VirtualBoxHost-OnlyNetWork?
    • ¥15 C# P/Invoke的效率问题
    • ¥20 thinkphp适配人大金仓问题
    • ¥20 Oracle替换.dbf文件后无法连接,如何解决?(相关搜索:数据库|死循环)
    • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号