简体   繁体   中英

Cant open Gnome terminal from php

I cant seem to open gnome terminal from php script tried DISPLAY=:0 did not work php code:::

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

test.sh shell script code

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

try this one

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

system.sh file should be like this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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