是不是有个什么命令能把本地 ssh 窗口命令 输送到远程 server 上执行? 我想本地的 Bitvise SSH Client 窗口输入一个命令 启动 server 上的 firefox? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
google456
V2EX    问与答

是不是有个什么命令能把本地 ssh 窗口命令 输送到远程 erver 上执行? 我想本地的 Bitvise SSH Client 窗口输入一个命令 启动 server 上的 firefox?

  •  
  •   google456 2015-03-14 15:44:47 +08:00 3815 次点击
    这是一个创建于 3947 天前的主题,其中的信息可能已经有所发展或是发生改变。
    google 一个
    ssh root@ip firefox
    貌似不对 还是无法启动 还是Error: no display specified

    当然直接在server端启动firefox是没有问题的
    14 条回复    2015-03-15 03:50:49 +08:00
    clino
        1
    clino  
       2015-03-14 15:46:04 +08:00 via Android
    ssh -X
    google456
        2
    google456  
    OP
       2015-03-14 16:15:51 +08:00
    @clino ssh -X root@ip firefox ??
    无效
    clino
        3
    clino  
       2015-03-14 16:47:58 +08:00 via Android
    @google456 看起来是windows下的应该就不支持了
    lululau
        4
    lululau  
       2015-03-14 16:58:04 +08:00
    ssh remote 'open /Applications/Firefox.app'

    这样?
    whoops
        5
    whoops  
       2015-03-14 16:58:13 +08:00   1
    是在想在x下下启动firefox吧
    export DISPLAY=:0.0
    firefox ¨www.v2ex.com¨
    ETiV
        6
    ETiV  
       2015-03-14 17:17:14 +08:00 via iPhone
    确定有显示器的话就 DISPLAY=:1 后接命令。export 出来也可以。
    我树霉派上用这个加 mplayer 看片儿的

    LS的 0.0 是啥意思?
    whoops
        7
    whoops  
       2015-03-14 17:27:09 +08:00
    @ETiV
    DISPLAY后面的变量含义是这样的
    [host]:<display>[.screen]
    0.0是第一个显示器的第一屏
    我的ubuntu启动并登陆x后export查看是declare -x DISPLAY=":0"
    whoops
        8
    whoops  
       2015-03-14 17:39:09 +08:00
    man X
    查看X的手册里面有详细说明
    From the user's perspective, every X server has a display name of the
    form:

    hostname:displaynumber.screennumber

    This information is used by the application to determine how it should
    connect to the server and which screen it should use by default (on
    displays with multiple monitors):
    hostname
    The hostname specifies the name of the machine to which the
    display is physically connected. If the hostname is not given,
    the most efficient way of communicating to a server on the same
    machine will be used.

    displaynumber
    The phrase "display" is usually used to refer to a collection
    of monitors that share a common set of input devices (keyboard,
    mouse, tablet, etc.). Most workstations tend to only have one
    display. Larger, multi-user systems, however, frequently have
    several displays so that more than one person can be doing
    graphics work at once. To avoid confusion, each display on a
    machine is assigned a display number (beginning at 0) when the
    X server for that display is started. The display number must
    always be given in a display name.

    screennumber
    Some displays share their input devices among two or more moni
    tors. These may be configured as a single logical screen,
    which allows windows to move across screens, or as individual
    screens, each with their own set of windows. If configured
    such that each monitor has its own set of windows, each screen
    is assigned a screen number (beginning at 0) when the X server
    for that display is started. If the screen number is not
    given, screen 0 will be used.
    google456
        9
    google456  
    OP
       2015-03-14 17:42:52 +08:00
    @whoops 感谢 你这个方法可以
    不过关闭本地ssh窗口 远程的浏览器也关闭了 怎么能让远程浏览器一直运行呢?
    google456
        10
    google456  
    OP
       2015-03-14 17:45:59 +08:00
    @lululau 不行 ssh: Could not resolve hostname remote: Name or service not known

    如果用 ssh root@ip remote 'open /Applications/Firefox.app'
    会说bash: remote: command not found
    whoops
        11
    whoops  
       2015-03-14 18:08:38 +08:00
    @google456
    两种方法,
    第一种是保持firefox在运行,你再执行firefox url的时候就会打开一个标签,退出ssh的时候也不会关闭。
    第二种是用nohup命令,你可以这样写
    nohup firefox v2ex.com&
    注意最后的&,不要丢掉了,这样你关闭ssh后或者启动firefox的终端后,firefox不会退出的。
    google456
        12
    google456  
    OP
       2015-03-14 18:24:18 +08:00
    @whoops 嗯 nohup我也想到了 也确实没问题.

    第一种方法 没看明白
    本来不就是firefox ¨www.google.com¨ 这样吗
    远程打开了google.com 但是关闭ssh窗口 firefox就直接关闭了.
    whoops
        13
    whoops  
       2015-03-14 18:29:21 +08:00
    @google456 用第二个方法吧,我表述有问题,保持firefox运行,这里的firefox运行不是由ssh启动的,你可以放到开机启动脚本中,登陆x后自启动,当你用ssh执行firefox url 后,再关闭,这个firefox进程不会随着你的ssh退出而退出的,忘了它吧,有点繁琐.
    xieyudi1990
        14
    xieyudi1990  
       2015-03-15 03:50:49 +08:00 via iPhone
    用screen目测也可以
    我的iPhone上就是用screen保持后台的.
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2422 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 23ms UTC 11:59 PVG 19:59 LAX 03:59 JFK 06:59
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86