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 多电路系统共用电源的串扰问题
    • ¥15 shape_predictor_68_face_landmarks.dat
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料