[tcljava-user] no output with exec in catch block
by Johannes Kleinlercher other posts by this author
Feb 3 2006 10:29AM messages near this date
RE: [tcljava-user] Tcl Extension
|
[tcljava-user] Stacktrace
Hi folks,
I have to execute a ksh-script in jacl and
react if this ksh-script exits with errors.
Additionally I need the output of the script on the screen (stdout).
So I did the following (I replaced my script with a simple 'hostname'
command)
========================
set status 0
if {[catch {exec hostname} results]} {
if {[lindex $::errorCode 0] == "CHILDSTATUS"} {
set status [lindex $::errorCode 2]
puts "Script exits with Errorcode $status"
} else {
puts "Script exits with unexpected error"
}
}
========================
However, then you can't see any output of 'exec hostname'.
Even if I put a 'puts' around the exec, I can see the output if everything works ok,
but not if something goes wrong (try to replace the hostname with 'blabla':
========================
set status 0
if {[catch {puts [exec blabla]} results]} {
if {[lindex $::errorCode 0] == "CHILDSTATUS"} {
set status [lindex $::errorCode 2]
puts "Script exits with Errorcode $status"
} else {
puts "Script exits with unexpected error"
}
}
========================
Any ideas or workarounds to catch the exec and see the output of it even if the script fails
?
thanks and best regards,
Johannes Kleinlercher
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
tcljava-user mailing list
tcljava-user@[...].net
https://lists.sourceforge.net/lists/listinfo/tcljava-user
|