hpSWfirmupgrade.sh isimli betiğimiz
#!/usr/bin/expect
set ip [lindex $argv 0]; set user [lindex $argv 1];
set password [lindex $argv 2]; set version [lindex $argv 3];
set prompt “:|>|#|\\\$”; set variable “Press any key to continue”;
eval spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no “$user\@$ip”
if { $version == “\”A.15.16.0021\””} {
interact -o -nobuffer -re $prompt return; send “$password\r”;
interact -o -nobuffer -re $variable return; send “\r”;
interact -o -nobuffer -re $prompt return; send “copy tftp flash 10.1.1.1 A_15_16_0021.swi secondary allow-no-signature\ry\r”;
} elseif { $version == “\”R.11.122\”” } {
interact -o -nobuffer -re $prompt return; send “$password\r”;
interact -o -nobuffer -re $variable return; send “\r”;
interact -o -nobuffer -re $prompt return; send “copy tftp flash 10.1.1.1 R_11_122.swi secondary\ry\r”;
} elseif {$version == “\”RA.16.04.0016\””} {
interact -o -nobuffer -re $prompt return; send “$password\r”;
interact -o -nobuffer -re $variable return; send “\r”;
interact -o -nobuffer -re $prompt return; send “copy tftp flash 10.1.1.1 RA_16_04_0016.swi secondary\ry\r”;
} else {
interact -o -nobuffer -re $prompt return; send “$password\r”;
interact -o -nobuffer -re $prompt return; send “en\rasdasdasdasd*\r”;
interact -o -nobuffer -re $prompt return; send “copy tftp://10.1.1.1/N1500v6.5.1.5.stk active\ry\r”;
interact -o -nobuffer -re $prompt return; send “reload\rn\r”;
interact -o -nobuffer -re $prompt return; send “configure\r”;
sleep 1; send “do write\ry\r”; sleep 1; send “exit\r”;
}
sleep 30;
interact -o -nobuffer -re $prompt return; send “reload\ry\r”;
interact -o -nobuffer -re $prompt return; send “logout\ry\r”;
interact
#!/bin/bash
# declare an array
declare -a arr=()
declare -a arrversion=()
declare -a output=()
echo “Güncelleme islemi baslasin”
#echo “Hp2615’ler güncellenmeye baslandi.”
#now=`snmpget -v 2c -c snmpstring -Ln 10.1.1.252 1.3.6.1.2.1.47.1.1.1.1.10.1 | cut -d ‘:’ -f 2`;
#echo “Mevut sürüm…: $now”;
#./hpSWfirmupgrade 10.1.1.252 manage anahtarpass $now
#echo “Hp2610’lar güncellenmeye baslandi.”
#now=`snmpget -v 2c -c snmpstring -Ln 10.1.1.15 1.3.6.1.2.1.47.1.1.1.1.10.1 | cut -d ‘:’ -f 2`;
#echo “Mevut sürüm…: $now”;
#exec /hpSWfirmupgrade 10.1.1.15 manage anahtarpass * $now
#./hpSWfirmupgrade 10.1.1.15 manage anahtarpass * $now
#echo “Hp2620’ler güncellenmeye baslandi.”
#now=`snmpget -v 2c -c public -Ln 10.1.1.222 1.3.6.1.2.1.47.1.1.1.1.10.1 | cut -d ‘:’ -f 2`;
#echo “Mevut sürüm…: $now”;
#./hpSWfirmupgrade 10.1.1.222 manage anahtarpass * $now
#echo “Hp2620’ler güncellenmeye baslandi.”
now=`snmpget -v 2c -c snmpstring -Ln 10.1.1.238 1.3.6.1.2.1.47.1.1.1.1.10.2 | cut -d ‘:’ -f 2`;
echo “Mevut sürüm…: $now”;
./hpSWfirmupgrade 10.1.1.238 manage anahtarpass * $now
echo “Job basariyla tamamlandi…”