【问题标题】:bash script to ssh into a box and get me to a python shellbash脚本ssh进入一个盒子,让我进入一个python shell
【发布时间】:2010-10-27 19:41:02
【问题描述】:

我想编写一个脚本,让我直接进入另一个盒子上的 python shell,这样我就不必先运行 ssh 再运行 python。

当我执行“ssh hostname python”时,它只是挂起 - 这与 python 是交互式的事实有关。 “ssh hostname cat x”工作正常。

是否有一些 ssh 选项可以完成这项工作?

【问题讨论】:

    标签: bash unix shell ssh


    【解决方案1】:
    ssh -t user@host python
    

    -t 标志强制 ssh 为连接分配一个伪终端。如果在 ssh 命令行上给出命令,通常它不会这样做,这会导致 python 以非交互模式运行。

    【讨论】:

      【解决方案2】:

      其实想通了,我需要做 ssh -t hostname python

      【讨论】:

        【解决方案3】:

        您需要 -t 选项来强制分配伪 tty

        ssh -t host python
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-12-06
          • 1970-01-01
          • 1970-01-01
          • 2019-01-26
          • 2013-09-26
          • 1970-01-01
          • 1970-01-01
          • 2012-06-05
          相关资源
          最近更新 更多