Re: How can i let shell program within TCL show run log?
- From: Alexandre Ferrieux <alexandre.ferrieux@xxxxxxxxx>
- Date: Wed, 18 Jun 2008 05:49:14 -0700 (PDT)
On Jun 18, 12:30 pm, Ahmad <ahmad.abdulgh...@xxxxxxxxx> wrote:
Hi Alex,
Thank you again.
Would you kindly explain the above example in a much easier way (i'm
quite newbie to Tcl unlike you expert!).
I don't understand batch of stuff:
- Is the ">@" operator part of Unix or Tcl syntax? What is it exactly
used in? What does advancing it with a number like 2>@ or a letter a>@
and so forth mean?
Look at the [exec] Tcl manpage for these strange <>@ beasts :-)
You'll find there that >@ means "redirect child's stdout to a Tcl
channel", and 2>@ the same for child's stderr.
- What happens when you execute: open "|cat" ??
Wow. New to unix too, right ?
As it turns out, 'cat' without arguments is just a "byte noria"
pumping its stdin to its stdout. So [open "|cat" r+] essentially gives
you a "free pipe": anything written on the write side of the channel
$pi can be read on the other side shortly thereafter. So when you say
set ff [open "|foo bar 2>@ $pi r]
you have the child's stdout to be pumped out of $ff, and its stderr to
be pumped out of $pi. OK ?
I can't understand either it or : open "|cmd args ... 2>@ $pi" . Does
the "..." mean specific thing? Would you please explain, again?
Sorry "cmd args ..." was my way of saying "your command and its
arguments" :-)
- Finally, i would really appreciat if you gave me an example that
could be directly ran to display a command output on a text widget (a
command like "cat" for a long file)
Beware that all the added complexity with the "free pipe" is needed
only if you want to distinguish what gets out of stdout from what gets
out of stderr. Not sure it is your case, you didn't say.
So here I'm giving the example in the simple case: no distinction.
Both stdout and stderr from the child mixed together:
We'll be using the unix command "vmstat" for this example, because it
outputs slowly and regularly:
Start wish and type:
text .t
pack .t
proc tolog ch {
if {[gets $ch line]<0} {close $ch;return}
.t insert end $line\n
}
set ff [open "|vmstat 1 2>@1" r]
fileevent $ff readable [list tolog $ff]
-Alex
.
- References:
- How can i let shell program within TCL show run log?
- From: Ahmad
- Re: How can i let shell program within TCL show run log?
- From: Alexandre Ferrieux
- Re: How can i let shell program within TCL show run log?
- From: Ahmad
- Re: How can i let shell program within TCL show run log?
- From: Alexandre Ferrieux
- Re: How can i let shell program within TCL show run log?
- From: Ahmad
- How can i let shell program within TCL show run log?
- Prev by Date: Re: snodbc: Serious performance issues
- Next by Date: Re: return and one proc calling another
- Previous by thread: Re: How can i let shell program within TCL show run log?
- Next by thread: how use a FTP SSL server?
- Index(es):
Relevant Pages
|
|