paramiko.SSHClient()的exec_command函数内部如何使用变量

#!/usr/bin/env python
#coding: utf-8

import paramiko
IP='xxx.xxx.xxx.xxx'
FILEPATH='/root/test/test'
LINE= 'user=lalala'
print(FILEPATH)
# 建立一个sshclient对象
ssh = paramiko.SSHClient()
# 允许将信任的主机自动加入到host_allow 列表,此方法必须放在connect方法的前面
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# 调用connect方法连接服务器
ssh.connect(hostname=IP, port=22, username='root', password='1111')
# 执行命令

command1="each $LINE"
command2="each user"
####################
##问题:
exec_command
为何使用变量不行,使用字符串可以   如何调整command1使其也能运行,要使用变量

##
####################
stdin1, stdout1, stderr1 = ssh.exec_command(command)
result1 = stdout1.read().decode('utf-8')
print(result1)
print(len(result1))


# 关闭连接
ssh.close()
原文地址:https://www.cnblogs.com/mathprogrammer/p/13051438.html