#!/usr/bin/tclsh package require Expect proc pne {x} { if {$x != ""} { puts $x } } set x 0 set L "" set C "" log_user 0 spawn clamscan eicar_test_files expect_before -re "((L|C)\[^\r\]*)\r" { set $expect_out(2,string) $expect_out(1,string) exp_continue } eof { pne $L pne $C pne $expect_out(buffer) puts "*** clamscan died! ***" exit 1 } expect "\n"; # newline after "Loading: ..." expect "\n"; # newline after "Compiling: ..." expect_before pne $L pne $C puts "" log_user 1 expect "FOUND" { incr x exp_continue } eof if {$x ne 3} { exit 1 }