Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #!/usr/bin/expect -f
- FILE1=dispositivos.csv #file with IP's and device name
- set Username "user" #this is the user for telnet connection.
- set Password "this.is.the.pass" #pass for telnet connection.
- NUMERODISP="$(wc -l $FILE1 | awk '{print $1}')" #this command counts number of devices (IP's) in the file as it is a .csv file, it only counts number of lines.
- for i in `seq 2 $NUMERODISP`;
- do
- IP="$(awk -vnum="$i" 'NR == num { print $NF }' dispositivoss.csv)"
- echo "$IP" #this takes the IP from last column from .csv file
- done
- for i in `seq 2 $NUMERODISP`;
- do
- IP="$(awk -vnum="$i" 'NR == num { print $NF }' dispositivoss.csv)"
- send "telnet $IPr"
- expect "Username:"
- send "$Usernamer"
- expect "Password: "
- send "$Passwordr"
- expect "*>"
- send "show versionr"
- log_file -noappend SN_$IP.dat;
- expect -ex "--More--" {send -- " "; exp_continue}
- expect "*>"
- log_file;
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement