从php脚本打开gnome-terminal [英] Open gnome-terminal from php script

查看:50
本文介绍了从php脚本打开gnome-terminal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试从php脚本打开gnome-terminal:

I want to try to open gnome-terminal from php script:

shell_exec('bash /data/manager/application/.shell/system.sh');

此脚本使用一个功能来检查终端:

This script use a function to check terminal:

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

runintoterminal () {
    if ! [ -t 1 ]; then
        gnome-terminal -e "bash $1"
        exit 0
    fi
}
runintoterminal $SCRIPTCURRENT

我尝试过:

shell_exec('gnome-terminal');

但这是行不通的...(我知道这是可能的...)但是要怎么做?

But it's doesn't work... (I know it's possible...) But how to ?

我使用nginx和php-fpm.用我自己的插座.Nginx和套接字使用我的用户,而不使用www-data.(我正在使用Ubuntu 14.04LTS)

I use nginx and php-fpm. With my own socket. nginx and socket use my user and not www-data. (I'm on ubuntu 14.04LTS)

我已经尝试了0777权限...

I've try 0777 rights...

我的bash脚本可以从netbeans IDE ans终端运行...但是不能从php ...

My bash script can run from netbeans IDE ans terminal... but not from php...

推荐答案

问题很可能是gnome-terminal不知道它应该在哪里绘制.通常,它显示在与启动它的程序(IDE,终端)相同的显示器上,但是Web服务器没有显示器,因此它不知道要去哪里.您可以尝试使用DISPLAY =:0 gnome-terminal -e"bash $ 1"在当前的第一个本地图形登录会话上显示它(如果具有该权限). 那个其他人

shell_exec('DISPLAY=:0 bash /data/manager/application/.shell/system.sh');

或关于功能:

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

runintoterminal () {
    if ! [ -t 1 ]; then
        DISPLAY=:0 gnome-terminal -e "bash $1"
        exit 0
    fi
}
runintoterminal $SCRIPTCURRENT

这篇关于从php脚本打开gnome-terminal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆