繁体   English   中英

Python执行ssh命令(仅用于远程端口转发的SSH服务器)并捕获输出

[英]Python execute ssh command(SSH server just for remote port forwarding) and capture the output

目前,我正在使用此命令运行ssh服务器,以使用Serveo进行远程端口转发

subprocess.call('ssh -R 80:127.0.0.1:5000 serveo.net', shell=True)

我需要从ssh命令提取URL并将其分配给变量。 有什么办法获取输出吗?

使用bash模块:

import bash
b = bash('ls tests.py')
b.stdout 'tests.py\n'
b.stderr ''

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM