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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sample Code

Status
Not open for further replies.

jainajay

Technical User
Joined
Apr 20, 2010
Messages
5
Location
CA
Hi i am trying to run this code from brent welch and it says file/directory not found .Basically i want to run a file from GUI and the output which appears on console should be redirected to the GUI text box.

code:
#!/usr/local/bin/wish
# execlog - run a program with exec and log the output
# Set window title
wm title . ExecLog
# Create a frame for buttons and entry.
frame .top -borderwidth 10
pack .top -side top -fill x
# Create the command buttons.
button .top.quit -text Quit -command exit
set but [button .top.run -text "Run it" -command Run]
pack .top.quit .top.run -side right
# Create a labeled entry for the command
label .top.l -text Command: -padx 0
entry .top.cmd -width 20 -relief sunken \
-textvariable command
pack .top.l -side left
pack .top.cmd -side left -fill x -expand true

# Create a text widget to log the output
frame .t
set log [text .t.log -width 80 -height 10 \
-borderwidth 2 -relief raised -setgrid true \
-yscrollcommand {.t.scroll set}]
scrollbar .t.scroll -command {.t.log yview}
pack .t.scroll -side right -fill y
pack .t.log -side left -fill both -expand true
pack .t -side top -fill both -expand true
# Run the program and arrange to read its input
proc Run {} {
global command input log but
if [catch {open "| $command |& cat"} input] {
$log insert end $input\n
} else {
fileevent $input readable Log
$log insert end $command\n
$but config -text Stop -command Stop
}
}
# Read and log output from the program
proc Log {} {
global input log
if [eof $input] {
Stop
} else {
gets $input line
$log insert end $line\n
$log see end
}
}
# Stop the program and fix up the button
proc Stop {} {
global input but
catch {close $input}
$but config -text "Run it" -command Run
}
 
i am typing file name in it .. so that it executes it .
if it doenot do that can you please tell me how to redirect the console output to gui frame.

Basically i want run a file from gui .The tcl file is stand alone and run through console interaction .Now i want use GUI so that when i press RUN button it executes and display output in GUI console .

Thanks in advance

Ajay
 
if i am wrong .what should be filename or the command that i put in :)
 
Hi

Ajay said:
i am typing file name in it .. so that it executes it .
I suppose it runs fine from the command line.

My best idea is that you have a script in the current directory and current directory is not in the [tt]PATH[/tt]. Makes any difference if you specify the script to run together with the path, either absolute or relative ?

Feherke.
 

i am using eclipse with tcl /tk plugin .No matter how i give file name it says -

couldn't execute "print.tcl": no such file or directory

the print file has -
while {1} {
puts "ajayu"
}


P.S. i want the "ajay " to be printed contimously in the log.
 
I was wondering if some one could help me out ..its really urgent
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top