Got a problem thats being doing my head in for the last 2 days.
Im running a tcl script (for an eggdrop) which when triggered, executes a local shell command (child process) and if the command is succesfull it spits out the results. However, if the command is NOT succesful, i get an error "Tcl error [proc_ports]: child process exited abnormally
:.
What i would like is to create a custom response, if the child process did not find any results.
The script is:
set chan "#help"
bind pub -|- .port proc_ports
proc proc_ports {nick host handle channel testes} {
global chan
if {"$chan" == "$channel"} {
return 0
}
if [matchattr $nick |fmn $channel] {
set ports [lindex $testes 0]
set fp [ exec grep -w "$ports" scripts/ports | awk {{$1=""; print $0}} ]
putserv "PRIVMSG $channel :Port \002$ports\002 is normally used for: \002$fp\002"
return 1
} else {
putserv "PRIVMSG $channel :$nick, you do \002NOT\002 have access to this command!"
return 1
}
}
I would love to solve this using TCL, to help me learn more, rather than changing the exec into a shell script that would return any errors.
I have read up on the CATCH command in TCL, and have tried many different approaches to the script, however all have failed me :(
Any help would be appreciated.
Cheers.