You are here: PHP Gurus, listen up! Re: How do you do TCL exec command on PHP script that uses user input? « PHP Programming Language « IT news, forums, messages
PHP Gurus, listen up! Re: How do you do TCL exec command on PHP script that uses user input?

Posted by comp.lang.tcl on 11/22/05 17:57

Ralf, at this point I will have to defer this to the PHP gurus out
there as this is beyond what I understand PHP to be able to do.

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). I just want to be sure I'm clear on
this before I proceed any further with asking PHP folk out there.

I tried the following in TCL to no avail:

[TCL]
if {[catch {exec php -q $root/scripts/php/info.php >@stdout} errMsg]} {
writeErr "Could not run PHP Script: $errMsg"
}
[/TCL]

[Note to PHP people: I believe this might work although I prefer a more
experted opinion:]

[PHP]
if (is_resource(STDERR)) @fputs(STDERR, $errMsg);
[/PHP]

Phil
Ralf Fassel wrote:
> * "comp.lang.tcl" <phillip.s.powell@gmail.com>
> | 4) If you just hit the carriage return, it throws an error message "You
> | must enter..." and dies
> --<snip-snip>--
> | However, when the same PHP script is now being accessed by the TCL
> | script, it does 1), you do 2), 3) occurs, but if you do 4), instead
> | of correctly throwing an error message and dying, it just keeps
> | going and lets you enter more "nonentities".
>
> TCL needs some way of knowing whether the PHP script was successful or
> not. If the PHP script always exits with status 0 even if no valid
> input was given, then TCL needs to check the output of the script.
>
> Here you have the problem that on the one hand, the user needs to see
> the prompt (redirect PHP stdout), on the other hand TCLs needs to see
> the error message.
>
> If you're lucky, you can change the PHP script to exit non-zero in
> case of invalid input. Then the 'catch' in TCL will trigger.
>
> If you're not *that* lucky, but still *somewhat* lucky, the "You must
> enter..." message from the PHP script goes to stderr. In that case
> just don't redirect stderr when exec'ing the PHP script. Then the
> 'catch' in TCL will trigger, since anything on stderr of a subprocess
> is considered an error in TCL.
>
> if {[catch {exec php -q $root >@stdout} err]} {
> puts "error while calling PHP:"
> puts "errorCode $::errorCode"
> puts "message: $err"
> }
>
> If the 'error' message of PHP also goes to stdout, you will have to
> use some other means (expect comes to my mind then), since then you
> will need to separate the prompt from the rest of the output.
>
> HTH & good luck!
> R'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация