python - 有什么方法可以通过heredocs在python中通过ssh允许STDIN吗?

标签 python bash ssh stdin

我有一个 bash 脚本,它接受 3 个参数。我需要 ssh 进入远程终端并使用这些参数执行 python 脚本。

    #!/bin/bash

    ssh -t -t -c blowfish -XC someServer << EOF
      python -u pythonToExecute.py $1 $2 $3
    EOF

Python 脚本采用这些参数,并根据某些组合,可能会要求用户指定一个操作(使用 raw_input)

我遇到的问题是 python 脚本在插入任何输入后挂起(假设 STDIN 存在问题)。

如果我在 ssh 调用中调用 python,则 python 脚本可以完美运行,但随后我无法使用 bash 参数。

我不能使用 Paramiko、fabric 或任何其他外部模块/包。

有什么想法吗?

最佳答案

像下面这样调用怎么样?

ssh someServer python -u pythonToExecute.py $1 $2 $3

“我无法使用 bash 参数。”是什么意思?意思是?

关于python - 有什么方法可以通过heredocs在python中通过ssh允许STDIN吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12979663/

相关文章:

python - string.format,不同长度打破表

python - 如何在通过 python 运行时将变量传递到 sql 文件中

python - 获取特定键的所有值

windows - Windows 7 中非常基本的 git 批处理

c++ - 使用 ssh 远程机器上的 Netcat

python - 在 Python 中执行多行

excel - 将 xlxs 文件转换为 csv

linux - Bash 将安装的文件夹检测为目录

linux - 使用脚本自动输入 SSH 密码

通过http ://does not clone all tags Git克隆