ネットワークデバイス構成(Ciscoデバイス)をバックアップするために、Exepct言語で次のサンプルスクリプトを実行しました
#!/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
ここで、スクリプトがcsvから$ deviceをロードするか、txtファイルからより単純にロードするようにします。つまり、私のtxtファイルに次のようにすべてのciscoipアドレスが含まれているとします。
192.168.244.20
192.158.244.21
...
192.168.244.245
そのスクリプトがtxtファイルをロードしたら、毎回1つのIPアドレスをロードし、そのIPアドレスを$ device変数に割り当ててから、コマンド「copyrunning-config ...」を作成します。どうすればよいですか?誰でも私を助けることができます