无法打开X服务器

发布于 2024-12-13 17:31:08 字数 385 浏览 9 评论 0原文

我试图在终端中生成 Firefox 窗口的屏幕截图,但我不断收到错误:

root@host [~]# DISPLAY=:1 firefox http://www.cnn.com & sleep 5 && DISPLAY=:1 import -window root -crop 1264x948+0+25 -quality 90 /usr/local/apache/htdocs/screenshot1.jpg && pkill firefox
[1] 30200
import: unable to open X server `:1' @ import.c/ImportImageCommand/364.

为什么会发生这种情况?我该如何修复它?

I am trying to generate a screenshot of a firefox window in my terminal, but I keep getting an error:

root@host [~]# DISPLAY=:1 firefox http://www.cnn.com & sleep 5 && DISPLAY=:1 import -window root -crop 1264x948+0+25 -quality 90 /usr/local/apache/htdocs/screenshot1.jpg && pkill firefox
[1] 30200
import: unable to open X server `:1' @ import.c/ImportImageCommand/364.

Why is this happening? How can I fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心房的律动 2024-12-20 17:31:08

例如,可以尝试 DISPLAY=:0 吗?

Maybe try DISPLAY=:0, for example?

蓝眸 2024-12-20 17:31:08

看起来您在启动后在终端中使用了 root 身份(或者您是否以 root 身份登录到 X?)。如果是这种情况,则无法打开显示器,因为它由另一个用户拥有,并且您不能只是去显示其他人的显示器上的内容。

退出 root 会话,它可能会起作用。如果您希望它在根会话中工作,请查看“man xhost”。

It looks like you used changed to root in the terminal after starting it (or did you login to X as root?). If that's the case the display can't be opened because it's owned by another user and you can't just go and display stuff somebody else's display.

Exit the root session and it will probably work. If you want it to work from the root session take a look at 'man xhost'.

洛阳烟雨空心柳 2024-12-20 17:31:08

您能告诉我们输入时的结果吗?

ls -la /tmp/ | grep X

另外

ps | grep X

,我在使用 DISPLAY=:1 语法时遇到了一些问题,所以我使用:

firefox --display=:1 URL_OF_SITE
import -display :1 -window root etc...

Can you tell us what are the result when you type

ls -la /tmp/ | grep X

and

ps | grep X

Also, I had some trouble with using the DISPLAY=:1 syntax, so instead I use:

firefox --display=:1 URL_OF_SITE
import -display :1 -window root etc...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文