I’ve done the following sample script in Exepct language to backup my network devices configuration (cisco devices)
#!/usr/bin/expect -f
# ---------------- configuration ---------------- #
set device 192.168.244.20
set user go00080
set pass password
set tftp 192.168.244.243
set timeout 60
# -------------- core -------------- #
spawn telnet $device
expect "Username:"
send "$user\n"
expect "Password:"
send "$pass\n"
send "copy running-config tftp://192.168.244.243\r"
expect "Address or name of remote host"
send "\r"
expect "Destination filename "
send "\r"
expect "secs"
send "exit\r"
close
exit 0
Now, I want that my script load $device from a csv or more simple from a txt file; I mean, suppose that my txt file contains all cisco ip address in the following way:
192.168.244.20
192.158.244.21
...
192.168.244.245
I want that script once loaded txt file, load one ip address each time, assign that ip address to $device variable and then make command “copy running-config…”
How can I do? Anyone can help me
For help on specific commands, see http://tcl.tk/man/tcl8.5/TclCmd/contents.htm