Previously I made a post about as execute externals pipe commands from an application using C language programming, now I was testing with PHP to execute pipes from a web page, this because many times I want run a linux script from a web page, but with < exec > function I cant run pipes commands, therefore I made the following script that let run pipe scripts commands from a web page with PHP:
if((!$echo_pipe) || (!$festival_pipe)){
fprintf(stderr,"One or both pipes failed.\n"); return EXIT_FAILURE; } $bytes_read=0; while($buffer=fread($echo_pipe,2096)){ fwrite($festival_pipe,$buffer); $bytes_read+=strlen($buffer); } printf("Total bytes read = %d\n",$bytes_read); if(pclose($echo_pipe)!=0){
fprintf(stderr,"Could not run 'echo', or other error.\n"); } if(pclose($festival_pipe)!=0){
fprintf(stderr,"Could not run 'festival', or other error.\n"); } ?>
The code show how to send information using pipes to festival app for speak the received text, in this case the process will be execute in the web server.
Using pipes in PHP you can make interesting things, for example to send SMS using Gnokii among other things..
Dejar un comentario