Re: exec/system/pasthru I NEED HELP!!!!

From: Date: Thu, 15 Mar 2001 17:23:10 +0000
Subject: Re: exec/system/pasthru I NEED HELP!!!!
References: 1  Groups: php.gtk 
Request: Send a blank email to php-gtk+get-931@lists.php.net to get a copy of this message
I found this works for putting the program opened in the background but I still connat send commands through it via fputs. Is there any other way to do this? works $process = popen ($command, 'w'); // to be able to send commands to it Not working! fputs ($process, "some command\r\n"); // send 'some command' followed by a crlf Is pclose supposed to close the prog. priginaly opened in this case? if so this does not work either! pclose ($process); // kill off the process ----- Original Message ----- From: "Mike" <rapacity-php@my.madness.com.au> To: "Josh Seward" <js389599@ohiou.edu> Cc: <php-gtk@lists.php.net> Sent: Thursday, March 15, 2001 11:37 AM Subject: Re: [PHP-GTK] exec/system/pasthru I NEED HELP!!!! > > > I need to run this program and send commands to it while its running. The > > program I am running excepts keyboard input commands, but I want my program > > to give it the commands it needs. Is there anyway of doing this? > > > > I want my program to launch a dos prgram (Does this then hangs?) and then > > send commands to the same program it just launched. > > > > Here is my code as is: > > > > $result = passthru($command."& 1> output.txt 2>&1; print output.txt; > > &", > > $pass); > > For one thing - that looks strangely like a UNIX-type command line, which > isn't going to work under Windows. Especially the '&' to run it in the > background. (Unless they've changed things significantly under NT/2k, which > I doubt) > > Anyway - if it is possible at all, you'll want to use popen() to do this. > Of course, popen() only allows you to send data to the program, or read it > from the program - not both. You may be able to redirect the output to a > file and read that, depending on buffering... > > Check the PHP manual for info on popen() - > http://www.php.net/popen > > But briefly: > > $process = popen ($command, 'w'); // to be able to send commands to it > fputs ($process, "some command\r\n"); // send 'some command' followed by a crlf > pclose ($process); // kill off the process > > You _might_ be able to use mode 'w+' to allow reading and writing, according > to some of the comments in the manual. I'll leave it to you to try it... > > -- > Michael. > > > -- > PHP GTK Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-gtk-unsubscribe@lists.php.net > For additional commands, e-mail: php-gtk-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.gtk (#931) next »