|
Posted by comp.lang.tcl on 11/22/05 23:16
It was easier than I thought! An extra PHP die() statement in the PHP
code was all it took for TCL to recognize the abruption and act
accordingly! I also took out the redirection to stderr and all was
fine!
Thanx to you and Cameron Laird (and Ulrich) for all of your help!
Phil
Ralf Fassel wrote:
> * "comp.lang.tcl" <phillip.s.powell@gmail.com>
> | If I am interpreting correctly, you want the PHP script to write to
> | stderr the specific error message if the user inputs "nothing" (i.e.,
> | just hits the carriage return).
>
> The best thing would be a non-zero exit status of the PHP script in
> this case. The second best thing would be a message to stderr.
>
> | [TCL]
> | if {[catch {exec php -q $root/scripts/php/info.php >@stdout} errMsg]} {
> | writeErr "Could not run PHP Script: $errMsg"
> | }
> | [/TCL]
>
> This 'catch' will trigger if:
> - the PHP script exits with nonzero status
> % catch {exec false}
> 1
> % set ::errorCode
> CHILDSTATUS 23911 1
>
> - the PHP script writes anything to stderr:
> % catch {exec sh -c {echo foo >&2}}
> 1
> % set ::errorCode
> NONE
>
> You distinguish the two cases by looking at errorCode, it is NONE in
> the case of normal exit (status 0) but some output on stderr.
>
> | [PHP]
> | if (is_resource(STDERR)) @fputs(STDERR, $errMsg);
> | [/PHP]
>
> Well, obviously this will not work as intended if
> 'is_resource(STDERR)' is false.
>
> R'
Navigation:
[Reply to this message]
|