从 Linux 终端启动 Web 浏览器(使用 ssh)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20429522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:34:05  来源:igfitidea点击:

Launching Web Browser from Linux Terminal (using ssh)

linuxsshterminalbrowser

提问by user1893354

I have ssh'd into my raspberry pi which uses Raspian OS (like Debian). I am trying to launch the default web browser from the terminal but I'm running into problems. I have looked at this post on launching web browsers from terminal. I have tried the xdg-openand the sensible-browsercommands however they seem to just display the desired webpage's contents within the terminal. So no actual web browser is launching in the raspberry pi (which is what I want). My default web browser is Midori. So am I using these terminal commands incorrectly, or am I misunderstanding what they are meant to do? To be clear, I want to actually launch the web browser in the dekstop environment using a terminal command. Thanks!

我已通过 ssh 连接到使用 Raspian 操作系统(如 Debian)的树莓派。我正在尝试从终端启动默认 Web 浏览器,但遇到了问题。我看过这篇关于从终端启动网络浏览器的帖子。我已经尝试了xdg-opensensible-browser命令,但是它们似乎只是在终端中显示所需网页的内容。所以没有在树莓派中启动实际的网络浏览器(这是我想要的)。我的默认网络浏览器是 Midori。那么我是否错误地使用了这些终端命令,还是我误解了它们的用途?明确地说,我想使用终端命令在 dekstop 环境中实际启动 Web 浏览器。谢谢!

采纳答案by chaos

graphic applications need an environment variable called $DISPLAYto start.

图形应用程序需要一个环境变量$DISPLAY来启动。

Start your browser in the terminal via ssh like this for exmaple:

通过 ssh 在终端中启动浏览器,例如:

user@host:~# DISPLAY=:0 firefox http://www.google.com

The browser will be started in the gui. In your case:

浏览器将在 gui 中启动。在你的情况下:

user@host:~# DISPLAY=:0 midori http://www.google.com

回答by jp-cm

On some raspbian (jessie with PIXEL) for this to work, we must add the user to the video group to avoid the "failed to open vchiq..." message with :

在某些 raspbian(带有 PIXEL 的 jessie)上,我们必须将用户添加到视频组以避免“无法打开 vchiq...”消息:

usermod -a -G video username

usermod -a -G 视频用户名

and to avoid the console to hang, open midori with "&" at the end :

为了避免控制台挂起,请在末尾使用“&”打开 midori:

DISPLAY=:0 midori http://www.google.com&

DISPLAY=:0 midori http://www.google.com&

They must be other cleanest methods, but to complete this post, this one fits, I hope.

它们必须是其他最干净的方法,但为了完成这篇文章,我希望这个适合。