06-06-2020, 02:47 +0200
Forum: Overvieweggdrophelp
Logs dont contain the data sent toward them.
AuthorPost
sumguy  05-15-2013, 18:16   | Expect logging issue
Member since 05/2013
3 Posts
I having trouble building external files; logs.  :wand:  :#:
The output files are either blank or have only one random line.
Im running this on Centos 6.4.

I want to build a list of ips that have good ping responses, then use that external file to run another routine.



Any help would be appreciated.



                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
set ifil [open "new" r]
set count 0
set bcount 0
set fcnb 999
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\r"
        }
        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 output
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
This post was changed automatically. Why?
thommey  05-15-2013, 19:01   Jabber
(Administrator)
Member since 03/2004
62 Posts
try moving both your [open .. w] statements to before the while loop, you should only be opening and closing these files once - not in a loop.
sumguy  05-15-2013, 19:07  
Member since 05/2013
3 Posts
tcsh ... I feel so foolish ..

been laid off for 8 months .. goes to show you how much you forget in a short time.

Thanks a lot man .. that fixed it .. pays to have a second pair of eyes !!

Best Regards.
Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen | Time: 155.8 msec, CPU time: 68.6 msec, 35 Database queries in 114.3 msec | 4 kB (17.4 kB) | Timezone: +0200