Python Reads Only Last Line In Text File
I am trying to read 2 IP address from text file and connect these devices and run the 'conf t' command on these devices. When i trying to do this job by following coding, python re
Solution 1:
Maybe, you wish to do that ?
import paramiko
username = "xxxx"
password = "yyyy"
f = open("C:\\Users\0\Desktop\\deneme.txt")
for line in f:
ip_address = line.strip()
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=ip_address, username=username, password=password)
print ("Successfull", ip_address)
remote_connection = ssh_client.invoke_shell()
remote_connection.send("conf t\n")
f.close()
Post a Comment for "Python Reads Only Last Line In Text File"