可以使用PHP运行导出DISPLAY吗? [英] can I run export DISPLAY with PHP?

查看:69
本文介绍了可以使用PHP运行导出DISPLAY吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试在PHP脚本中运行命令export DISPLAY,它将无法正常工作,但是如果我通过命令行运行,它将可以正常工作.这是一个已知问题还是有更好的方法?

If I try to run the command export DISPLAY inside my PHP script it fails to work but if I run it via command line it does work. Is this a known issue or is there a better way?

正在通过网页调用脚本.

The script is being called via a webpage.

我的PHP命令:

$process = 'export DISPLAY=:0 && ' . $command;
exec("$process $htmlname $exportname");

从网页运行时看到的错误是:

The error I see when running from the webpage is:

Gtk-WARNING **: cannot open display:

推荐答案

例如,您可以在系统调用之前设置环境. http://php.net/manual/en/function.putenv.php .这可能会导致在Web服务器桌面上打开一个窗口.您可能还需要使用xhost +

You can set up environment before system call with e.g. http://php.net/manual/en/function.putenv.php . This could cause a window open on the webserver desktop. You might also need to disable X11 xauth authentication with xhost +

这篇关于可以使用PHP运行导出DISPLAY吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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