无法打开X服务器
我试图在终端中生成 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
例如,可以尝试
DISPLAY=:0
吗?Maybe try
DISPLAY=:0
, for example?看起来您在启动后在终端中使用了 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'.
您能告诉我们输入时的结果吗?
另外
,我在使用 DISPLAY=:1 语法时遇到了一些问题,所以我使用:
Can you tell us what are the result when you type
and
Also, I had some trouble with using the DISPLAY=:1 syntax, so instead I use: