My logs aren't correct. Im trying to log failure and successes, then use the resulting successes file "seed" to perform another function. Problem is that the log has only a single random entry.
Thanks in advance for the help !
!#/usr/bin/expect
set count 0
set bcount 0
set fcnb 923
set ifil [open "new" r]
while { [gets $ifil host] >=0 } {
set timeout 4
log_user 0
set err [open $fcnb.errlog w]
set oseed [open "seed" w]
spawn ping -c1 $host
expect {
"rtt" {
set count [expr $count + 1]
puts "$count $host ping ok"
puts $oseed "$host"
#puts $oseed "$host\n"
}
default {
set bcount [expr $bcount + 1]
puts "Error : $bcount $host ping nok"
puts $err "$bcount $host ping nok"
#continue
}
}
}
close $ifil
close $oseed
close $err
# End ping while
#sleep 5
puts "==============================================="
puts "loop through the file of \"good\" pings"
puts "==============================================="
set iseed [open "seed" r]
while { [gets $iseed ip] >=0 } {puts $ip}
close $iseed
The ouput
1 10.121.216.54 ping ok
2 10.121.218.106 ping ok
3 10.121.218.14 ping ok
Error : 1 153.89.89.234 ping nok
4 10.121.218.82 ping ok
Error : 2 135.99.89.89 ping nok
5 10.122.178.122 ping ok
loop through the file of "good" pings
10.122.178.122
---------- Post updated 05-16-13 at 05:29 AM ---------- Previous update was 05-15-13 at 10:38 AM ----------
TSCH !! The answer is to take the opens out of the loop !