Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirecting stdout without using exec

Status
Not open for further replies.

argoto

Programmer
Aug 10, 1999
1
US
Hello, <br>
<br>
This one should be so easy - but I'm stumped... I need to redirect stdout from the following code to a file. The procedures "cmp" and "FlushEventQueue" are not under my control, so I cannot edit them in any way. Neither procedure returns stdout upon exiting. Also, this is tcl8.0 embedded in another application called Quartus.<br>
<br>
#**** BEGIN code from which i ****<br>
#**** need to redirect stdout ****<br>
<br>
while { [cmp is_running ] } {<br>
after 100 <br>
FlushEventQueue<br>
}<br>
<br>
#**** END code from which i ****<br>
#**** need to redirect stdout ****<br>
<br>
I've tried the following: <br>
* embedding all of it in a puts statement<br>
* embedding just FlushEventQueue in a puts statement <br>
* write the command to a var and use eval in a puts stmnt<br>
* using exec to divert stdout with "&gt;&@ $LogFileID" <br>
<br>
the last one doesn't work because these are procedures, not processes, so exec fails. <br>
<br>
Any suggestions? Again, this really should not be so difficult. One thing I'd like to try is to reassign the stdout handle to a filehandle, so that while it is assigned to that file, ANY stdout goes to the file. <br>
<br>
I would like to avoid launching an extra process with just this piece of code (using &gt; in dos), because this portion of code is dependent on lines upon lines of previous code., and well, it would just be so ugly. I mean, this has to be possible, right?<br>
<br>
thanks for your time, <br>
<br>
argo
 
I'd like to do the same thing but I'm stumped as well....anyone??<br><br>-- <br>Andy Bell<br>abell*at*engr.uvic.ca
 
One particular flavour of embedded tcl interpreter I've used, the Synopsys &quot;Formality&quot; tool for performing formal verification of electronic circuits, simply honoured the &quot;>&quot; and &quot;>>&quot; just like a c-shell or similar.
Mind you, they appear to have removed the feature in the latest release!
This seemed to be a particularly useful enhancement for solving problems of this kind. It made me feel vaguely uneasy; I thought that there must be some fundamental design-feature of tcl being violated. I'm still trying to find why they removed the feature...
 
try something like:

catch {FlushEventQueue} flush_result

flush_result should contain any stdout or stderr generated by FlushEventQueue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top