我有本地机器(windows)中的hosts_file中存储的IP地址列表,运行以下代码,从windows上运行远程linux服务器上的命令。
def set_hosts():
env.hosts = open('hosts_file.txt', 'r').readlines()
env.user = 'root'
def display_os():
run('ls -lart')
hosts_file.txt 包含以下条目
'192.168.56.101'
'192.168.56.102'
当我执行上面的代码时出现以下错误
['192.168.56.101'] Executing task 'display_os'
['192.168.56.101'] run: ls -lart
Warning: Name lookup failed for '192.168.56.101'
Underlying exception:
getaddrinfo failed
['192.168.56.102'] Executing task 'display_os'
['192.168.56.102'] run: ls -lart
Warning: Name lookup failed for '192.168.56.102'
Underlying exception:
getaddrinfo failed
Done.
我还检查了尾随空格,但不确定为什么会抛出错误。