我正在尝试构建并运行ssh命令为“ssh -p 29418 servacc@company.com gerrit review --option 1 change,patchnum”基于更改 和patchnum,谁能提供guidane如何做到这一点?
change = '700293'
patchnum = '1'
def lock (change,patchnum):
#Construct ssh command
#ssh -p 29418 servacc@company.com gerrit review --option 1 change,patchnum
lock(change,patchnum)
答案 0 :(得分:0)
您正在寻找系统调用 - 使用subprocess模块:
from subprocess import call
def lock(change,patchnum):
#Construct ssh command
#ssh -p 29418 servacc@company.com gerrit review --option 1 change,patchnum
call(["ssh -p 29418 servacc@company.com gerrit review --option 1 %d,%d" %(change,patchnum)],shell=True)
change = 700293
patchnum = 1
lock(change,patchnum)