Tri*_*tos 9 scripting ssh remote remote-control
我希望在远程机器的磁盘上运行本地的 python 脚本。我曾经像这样运行 bash 脚本:
cat script.sh | ssh user@machine
Run Code Online (Sandbox Code Playgroud)
但我不知道如何对 Python 脚本做同样的事情。
正如其他人所说,将其通过管道传输到 ssh。但是你要做的是给出适当的论据。您将需要添加-u以正确从 ssh 获取输出。并希望添加-处理输出和以后的参数。
ssh user@host python -u - < script.py
Run Code Online (Sandbox Code Playgroud)
如果要提供命令行参数,请将它们添加到-.
ssh user@host python -u - --opt arg1 arg2 < script.py
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31839 次 |
| 最近记录: |