不能从PHP打开Gnome终端

时间:2018-05-08 19:30:39

标签: php shell

我似乎无法从php脚本打开gnome终端 试过DISPLAY =:0不起作用 php code :::

  <?php 
  shell_exec("/opt/lampp/htdocs/py/test.sh");
  ?>

test.sh shell脚本代码

#!/bin/sh
gnome-terminal --working-directory=/opt/lampp/htdocs/py -x python3 MaxTemperature.py

1 个答案:

答案 0 :(得分:-1)

尝试这个

shell_exec('DISPLAY=:0 bash /opt/lampp/htdocs/py/test.sh');

system.sh文件应该是这样的

SCRIPTCURRENT=`readlink -m $0`
SCRIPTCURRENTPATH=$(dirname "$SCRIPTCURRENT")

    runintoterminal () {
        if ! [ -t 1 ]; then
            DISPLAY=:0 gnome-terminal --working-directory=/opt/lampp/htdocs/py -x python3 MaxTemperature.py
            exit 0
        fi
    }
 runintoterminal $SCRIPTCURRENT