你可以将以上代码转换为如下形式来传递参数:
import paramiko
import time
# 定义要执行的命令和参数
order = f'python3 {pyScript} -b {binaryFiles} -e -s {BURN_COM} -k {BURN_VERSION} -i {BURN_IP} --boot-fw {BURN_BOOT_PATH} --active-fw {BURN_PRODUCTION_TEST_PATH} --passive-fw {BURN_APP_PATH} --customer-config {BURN_CUSTOMER_CONFIG_PATH} --production-data {BURN_BUILD_PATH}'
try:
ssh = paramiko.SSHClient()
# 连接SSH服务器,具体参数根据实际情况进行设置
ssh.connect(hostname=hostname, username=username, password=password)
channel = ssh.invoke_shell()
channel.send(order + '\n')
Status = 0
while Status < 2:
time.sleep(0.1)
stdout = channel.recv(1024)
print(stdout.decode().replace('\r', ''))
if "Burn M1908" in stdout.decode():
Status += 1
except Exception as e:
print('Fail to carry out command:', str(e))
finally:
if ssh is not None:
ssh.close()
注意,你需要根据实际情况修改 hostname
、username
和 password
,并确保你的代码中包含了对paramiko库的导入语句。另外,这里假设你已经定义了变量 pyScript
、binaryFiles
等,用于替换命令中的占位符。
内容由零声教学AI助手提供,问题来源于学员提问