#!/usr/bin/expect log_file -a imet_log send_log "Beinning of data logging [exec date]\n" set timeout -1 set i 0 while {1} { ;#while loop for infinity incr i set x [exec date] ;#gets date from system set day [string range "$x" 8 9] ;#sets x equal to day spawn matlab set nday $day puts $nday send_log "start while loop [exec date]\n" send_log " $nday" while {$day == $nday} { ;#tests that it is the same day set x [exec date] set day [string range "$x" 8 9] send "try\n" ;#runs mfile expect ">>" exec sleep 60m ;#sleeps for 5min btw runs } expect "$" system "cat /dev/null > capture" :#empty the caputer file }