I have a CSV file containging entries like this :
ipaddress,VLAN,VLANid 10.192.168.1,vlan-xyz,3 10.192.168.1,vlan-abc,8 10.192.168.1,vlan-mnp,11 10.192.163.24,vlan-llz,3 10.192.163.24,vlan-bbz,5 10.192.163.24,vlan-xggz,23
and so on and i need to execute some cisco commands on remote cisco switches like :
now if i do somehting like this
while read ipaddress vlan vlanid ssh user@ipaddress << 'ENDSSH' int VLAN vlan-xyz switchport access vlan vlanid wr ENDSSH done < inputfile
it is going to ssh everytime and prompt me for password for each and every line in the file even for the same ipaddress. Is there any way to get over with this. I was thinking of putting a the other two columns in the file into an array like for a single ip addresses:
eg for IP:10.192.168.1 array=" int VLAN vlan-xyz switchport access vlan 3 wr int VLAN vlan-abc switchport access vlan 8 " for next ip ......
and so on
how do i do this so that i can just pass an array of command for an ip like this :
while read ipaddress ssh user@ipaddress " $array" done < inputfile
but still i need to make sure that if i get the similar ipaddress in the while loop it should not ssh into it but only when it finds a new ipaddress.
I am using empty to pass the password non-interactively to the remote switch using ssh but its not very good also beacuse it doesn't hrough any erros if the remote commands fail.everything including passwords are logged into its log file.
NOTE : all the ips have the same password for a user