| 
 Posted by Ralf Fassel on 11/22/05 18:17 
* "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'
 
[Back to original message] 
 |