在windows上运行python在远程服务器上调用带参数的shell脚本
我需要从windows运行python脚本。此脚本需要在远程linux服务器上运行shell脚本。调用shell脚本时,需要将一些参数传递给shell脚本 我使用paramiko库创建了一个python脚本,它确实可以登录到远程linux服务器并在那里执行一些命令 但我不明白如何用一个带参数的shell脚本调用来替换这些命令 这是我使用的代码(根据):在windows上运行python在远程服务器上调用带参数的shell脚本,python,Python,我需要从windows运行python脚本。此脚本需要在远程linux服务器上运行shell脚本。调用shell脚本时,需要将一些参数传递给shell脚本 我使用paramiko库创建了一个python脚本,它确实可以登录到远程linux服务器并在那里执行一些命令 但我不明白如何用一个带参数的shell脚本调用来替换这些命令 这是我使用的代码(根据): import paramiko hostname = "192.168.1.101" username = "test" passwo
import paramiko
hostname = "192.168.1.101"
username = "test"
password = "abc123"
commands = [
"pwd",
"id",
"uname -a",
"df -h"
]
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(hostname=hostname, username=username, password=password)
except:
print("[!] Cannot connect to the SSH Server")
exit()
for command in commands:
print("="*50, command, "="*50)
stdin, stdout, stderr = client.exec_command(command)
print(stdout.read().decode())
err = stderr.read().decode()
if err:
print(err)