Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #!/bin/bash
  2. #!/usr/bin/expect -f
  3. FILE1=dispositivos.csv #file with IP's and device name
  4. set Username "user" #this is the user for telnet connection.
  5. set Password "this.is.the.pass" #pass for telnet connection.
  6.  
  7. 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.
  8.  
  9.  
  10. for i in `seq 2 $NUMERODISP`;
  11. do
  12. IP="$(awk -vnum="$i" 'NR == num { print $NF }' dispositivoss.csv)"
  13. echo "$IP" #this takes the IP from last column from .csv file
  14. done
  15.  
  16. for i in `seq 2 $NUMERODISP`;
  17. do
  18. IP="$(awk -vnum="$i" 'NR == num { print $NF }' dispositivoss.csv)"
  19. send "telnet $IPr"
  20. expect "Username:"
  21. send "$Usernamer"
  22. expect "Password: "
  23. send "$Passwordr"
  24. expect "*>"
  25. send "show versionr"
  26. log_file -noappend SN_$IP.dat;
  27. expect -ex "--More--" {send -- " "; exp_continue}
  28. expect "*>"
  29. log_file;
  30. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement