Hello everybody
I'm trying to run two tcl scripts in parallel in such a way that one of the tcl script executes the other. Besides, the process of one depends on the output file(trace) of the other and vice versa. I simplified the problem into very understandable procedures so that you guys can help me in this one and I'll implemented in my scenario.
The following procedures are written in different TCL scripts.
proc tcl1 { } {
exec tcl tcl2.tcl &
set ff [open out1.tr w]
puts $ff "procedure1 line1"
set in1 [open "out2.tr" r]
gets $in1 line
puts $ff "1 $line"
close $in1
close $ff
}
tcl1
proc tcl2 { } {
set ff [open out2.tr w]
puts $ff "procedure2 line1"
set in1 [open "out1.tr" r]
gets $in1 line
puts $ff "1 $line"
close $in1
close $ff
}
tcl2
The aim of these two processes is that at the beginning, procedure 1 writes a line "procedure1 line1" on a file out1.tr. And Procedure 2 writes a line ""procedure2 line1" on file out2.tr. Then procedure1 reads the first line in out2.tr and writes it on the second line of its file out1.tr. Procedure 2 reads the first line in out1.tr and writes it on the second line of out2.tr. The intended outputs would be:
in out1.tr:
procedure1 line1
procedure2 line1
in out2.tr:
procedure2 line1
procedure1 line1
The procedure that I gave wouldn't run simply because the first line outputs are not ready by the time one wants to read the other. Can you help me with a mechanism that can force the procedures to wait for an output?
Thanks a lot,
Kamil
I'm trying to run two tcl scripts in parallel in such a way that one of the tcl script executes the other. Besides, the process of one depends on the output file(trace) of the other and vice versa. I simplified the problem into very understandable procedures so that you guys can help me in this one and I'll implemented in my scenario.
The following procedures are written in different TCL scripts.
proc tcl1 { } {
exec tcl tcl2.tcl &
set ff [open out1.tr w]
puts $ff "procedure1 line1"
set in1 [open "out2.tr" r]
gets $in1 line
puts $ff "1 $line"
close $in1
close $ff
}
tcl1
proc tcl2 { } {
set ff [open out2.tr w]
puts $ff "procedure2 line1"
set in1 [open "out1.tr" r]
gets $in1 line
puts $ff "1 $line"
close $in1
close $ff
}
tcl2
The aim of these two processes is that at the beginning, procedure 1 writes a line "procedure1 line1" on a file out1.tr. And Procedure 2 writes a line ""procedure2 line1" on file out2.tr. Then procedure1 reads the first line in out2.tr and writes it on the second line of its file out1.tr. Procedure 2 reads the first line in out1.tr and writes it on the second line of out2.tr. The intended outputs would be:
in out1.tr:
procedure1 line1
procedure2 line1
in out2.tr:
procedure2 line1
procedure1 line1
The procedure that I gave wouldn't run simply because the first line outputs are not ready by the time one wants to read the other. Can you help me with a mechanism that can force the procedures to wait for an output?
Thanks a lot,
Kamil