From: sandip g. <san...@gm...> - 2009-09-14 14:01:42
|
Hi all, I want to write a tcl script to iterate through all the folders in the current dir, and then check for a file in each. If present, I wish to perform some file operations (writing to a common file). My code looks like this: #Putting all folders (test cases) in current dir into a variable list tc [glob -type d *] #Creating the report for test case summary - this is the common file. set rptr [open "report.txt" w] set exectime1 [clock format [clock seconds]] puts $rptr "Execution time begins: $exectime1" puts $rptr "----------------------------------------------------------------------------------------------------\n" puts $rptr "No Test Case Result\n" puts $rptr "----------------------------------------------------------------------------------------------------" foreach a $tc { #No of cases executed: set n 1 cd "$a" puts "cd done.." if [file exists "executionResult.txt"] { # This is the file to check set fp [open "executionResult.txt" r] puts "inside if..." set data [read $fp] puts $rptr "setting data..." set data [split $data "\n"] puts "setting data123..." if {$data == "Pass"} { puts "setting data12345..." puts $rptr "$n $a Pass" } } else { puts $rptr "$n $a Fail" } incr n cd .. } close $rptr When I run it I get an error: can't read "tc": no such variable However the initial part of the report.txt file gets printed. Can someone identify what's going wrong here...im quite perplexed Thanks -- Sandip |