Hi all,
I trying to write the ouput of a program to a tk text widget. The program involved here is the top utility. I am creating a pipe and fileevent to see the information live. My code works if the open command is as follows:
if {[catch {open "|top -u $username -b" r+} input] } {
But the problem is I want to see the outout of only a particular process (a program called 'paraprof' in my case). So I do a grep on the top output as follows:
if {[catch {open "|top -u $username -b |grep paraprof" r+} input] } {
I get no output in the widget in this case. I guess it is due to the other pipe symbol. Is it considered to be a special character by the open command. I have no clue. I have tried many things by to no avail. Hope I will get a solution here. The complete functions inside which I am using this is shown below.
Thank you..
Johnny.
************************************************************
proc redirectnew {} {
global infile input
if {[catch {open "|top -u $username -b|grep paraprof" r+} input] } {
.txt insert end $input \n
} else {
#flush $input
fconfigure $input -blocking 0
fileevent $input readable updateText_new
.txt insert end $input \n
}
}
proc updateText_new {} {
global input
if [eof $input] {
catch {close $input}
} else {
gets $input line
.txt insert end $line\n
.txt see end
}
************************************************************
I trying to write the ouput of a program to a tk text widget. The program involved here is the top utility. I am creating a pipe and fileevent to see the information live. My code works if the open command is as follows:
if {[catch {open "|top -u $username -b" r+} input] } {
But the problem is I want to see the outout of only a particular process (a program called 'paraprof' in my case). So I do a grep on the top output as follows:
if {[catch {open "|top -u $username -b |grep paraprof" r+} input] } {
I get no output in the widget in this case. I guess it is due to the other pipe symbol. Is it considered to be a special character by the open command. I have no clue. I have tried many things by to no avail. Hope I will get a solution here. The complete functions inside which I am using this is shown below.
Thank you..
Johnny.
************************************************************
proc redirectnew {} {
global infile input
if {[catch {open "|top -u $username -b|grep paraprof" r+} input] } {
.txt insert end $input \n
} else {
#flush $input
fconfigure $input -blocking 0
fileevent $input readable updateText_new
.txt insert end $input \n
}
}
proc updateText_new {} {
global input
if [eof $input] {
catch {close $input}
} else {
gets $input line
.txt insert end $line\n
.txt see end
}
************************************************************