[PHP] popen and pclose. Something changed in 4.4.2 ! ....Fixed
On windows, allow Apache service to interact with the desktop... in the services manager GUI Rgds Venkat ** Greetings! I was using popen and pclose on a previous version of PHP on Windows with an older version of Apache (2.x). ( I think it was 4.4.1 but will need to check as i am not sure). pclose(popen(start . $exe . . $args, r)) Where $exe is my path to the batch file and $args are the arguments for the batch file. The batch file, in turn calls other batch files on a shared folder on a different PC On Windows, it would open up the dos window and run commands there and exit and the PHP script that called the pclose would terminate loading on the users' browsers. Now, with PHP 4.4.2, the pclose and popen send the tasks to the background and the dos window does not show up! As a result, killing the dos process is not possible (i get access denied in windows...) and the users cannot see the dos window when it runs. I would like the php script to send the commands to a dos window, and the php script to finish executing. I tried passthru, system, exec and proc_open... and none of them work. None of them bring up the dos window. Please help! Regards Venkat
[PHP] popen and pclose. Something changed in 4.4.2 !
Greetings! I was using popen and pclose on a previous version of PHP on Windows with an older version of Apache (2.x). ( I think it was 4.4.1 but will need to check as i am not sure). pclose(popen(start . $exe . . $args, r)) Where $exe is my path to the batch file and $args are the arguments for the batch file. The batch file, in turn calls other batch files on a shared folder on a different PC On Windows, it would open up the dos window and run commands there and exit and the PHP script that called the pclose would terminate loading on the users' browsers. Now, with PHP 4.4.2, the pclose and popen send the tasks to the background and the dos window does not show up! As a result, killing the dos process is not possible (i get access denied in windows...) and the users cannot see the dos window when it runs. I would like the php script to send the commands to a dos window, and the php script to finish executing. I tried passthru, system, exec and proc_open... and none of them work. None of them bring up the dos window. Please help! Regards Venkat
Re: [PHP] popen and pclose. Something changed in 4.4.2 !
I can only suggest you change the default settings on the MS-DOS application thingie... Right-click the MS-DOS icon in the Start menu, mess with settings like run in background etc. I suspect that it is a configuration of MS-DOS window issue, and has nothing to do with PHP. On Mon, June 12, 2006 3:09 am, Venkatesh M. S. wrote: Greetings! I was using popen and pclose on a previous version of PHP on Windows with an older version of Apache (2.x). ( I think it was 4.4.1 but will need to check as i am not sure). pclose(popen(start . $exe . . $args, r)) Where $exe is my path to the batch file and $args are the arguments for the batch file. The batch file, in turn calls other batch files on a shared folder on a different PC On Windows, it would open up the dos window and run commands there and exit and the PHP script that called the pclose would terminate loading on the users' browsers. Now, with PHP 4.4.2, the pclose and popen send the tasks to the background and the dos window does not show up! As a result, killing the dos process is not possible (i get access denied in windows...) and the users cannot see the dos window when it runs. I would like the php script to send the commands to a dos window, and the php script to finish executing. I tried passthru, system, exec and proc_open... and none of them work. None of them bring up the dos window. Please help! Regards Venkat -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] popen() in 4.3.2
My webhost just upgraded to php 4.3.2, and now I have a problem with popen. I'm opening an output buffer then piping it through htmltidy to make nice looking output. ?php ob_start(); // Other unimportant coding goes here $str=addslashes(ob_get_contents()); $fp=popen(echo \ . $str . \ | /bin/tidy - config /my/home/htmlrc, r); @$newstr=fread($fp, 99); ob_end_clean(); header(Last-Modified: . $gmt_modtime); header( Content-length: . strlen( $newstr ) ); echo stripslashes($newstr); ? This code worked perfectly before the upgrade, now strlen( $newstr ) is only getting back 4096 bytes. Is anybody else having this issue, and how can I fix this? I don't see any configuration setting that looks like it fits to this situation. It is running under redhat with Apache/1.3.27 Thanks, Jeff -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] popen() in 4.3.2
PHP 4.3.0-1 has a bug that made your previous code work, have a look at the fread() docs for why, here's a quote: Note: When reading from network streams or pipes, such as those returned when reading remote files or from popen() and proc_open(), reading will stop after a packet is available. This means that you should collect the data together in chunks as shown in the example below. It goes on to show that you must loop threw it to get fread() to do what you want in the below code. Although, the example it eludes to is wrong (a correct example will show when the manual next builds), you get the point... :) Regards, Philip On Sat, 7 Jun 2003, Jeff Harris wrote: My webhost just upgraded to php 4.3.2, and now I have a problem with popen. I'm opening an output buffer then piping it through htmltidy to make nice looking output. ?php ob_start(); // Other unimportant coding goes here $str=addslashes(ob_get_contents()); $fp=popen(echo \ . $str . \ | /bin/tidy - config /my/home/htmlrc, r); @$newstr=fread($fp, 99); ob_end_clean(); header(Last-Modified: . $gmt_modtime); header( Content-length: . strlen( $newstr ) ); echo stripslashes($newstr); ? This code worked perfectly before the upgrade, now strlen( $newstr ) is only getting back 4096 bytes. Is anybody else having this issue, and how can I fix this? I don't see any configuration setting that looks like it fits to this situation. It is running under redhat with Apache/1.3.27 Thanks, Jeff -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] popen() in 4.3.2
Wow. 6 minutes for a response. Of course, I thought my error was in the popen(), not fread(), so I didn't even check there. I've just fixed the code, and it works! Thanks, Philip. On Jun 8, 2003, Philip Olson claimed that: | |PHP 4.3.0-1 has a bug that made your previous code work, |have a look at the fread() docs for why, here's a quote: | | Note: When reading from network streams or pipes, such | as those returned when reading remote files or from | popen() and proc_open(), reading will stop after a packet | is available. This means that you should collect the data | together in chunks as shown in the example below. | |It goes on to show that you must loop threw it to get |fread() to do what you want in the below code. Although, |the example it eludes to is wrong (a correct example will |show when the manual next builds), you get the point... :) | |Regards, |Philip | | |On Sat, 7 Jun 2003, Jeff Harris wrote: | | My webhost just upgraded to php 4.3.2, and now I have a problem with | popen. I'm opening an output buffer then piping it through htmltidy to | make nice looking output. | | ?php | ob_start(); | // Other unimportant coding goes here | | $str=addslashes(ob_get_contents()); | $fp=popen(echo \ . $str . \ | /bin/tidy - config /my/home/htmlrc, r); | @$newstr=fread($fp, 99); | ob_end_clean(); | header(Last-Modified: . $gmt_modtime); | header( Content-length: . strlen( $newstr ) ); | echo stripslashes($newstr); | ? | | | This code worked perfectly before the upgrade, now strlen( $newstr ) is | only getting back 4096 bytes. Is anybody else having this issue, and how | can I fix this? I don't see any configuration setting that looks like it | fits to this situation. It is running under redhat with Apache/1.3.27 | | Thanks, Jeff | -- -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] popen(); problem, the function don`t finds the command......
Hi!! i`ve wrote a little script to run under shell, so this script: #!/usr/bin/php $saslpasswd = /usr/sbin/saslpasswd -p $username; $saslproc = popen($saslpasswd,w); fputs($saslproc, $passwd); pclose($saslproc); php-parser gives me the following as output: # sh: /saslpasswd: No such file or directory # what i`m doing wrong?? please help. bye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] popen(); problem, the function don`t finds the command...
Hi!! i`ve wrote a little script to run under shell, so this script: #!/usr/bin/php $saslpasswd = /usr/sbin/saslpasswd -p $username; $saslproc = popen($saslpasswd,w); fputs($saslproc, $passwd); pclose($saslproc); php-parser gives me the following as output: # sh: /saslpasswd: No such file or directory # what i`m doing wrong?? please help. bye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] popen
Hi, is anyone know how to make popen command to read and write to a process at the same time? My php script need to call linux command which requires interactive action, or anyone know other possible way of doing it? Regards, Lau NH
[PHP] popen
Please Cc: me with responses. I dunno how soon I'll be able to read php-general again... Short version: If a program doesn't take data from stdin, and you want to get data to it more securely than writing it to a file, is there some combination of exec/popen and/or Un*x redirection | that will get the data to go from PHP to the program, without hitting disk, and without being in ps -aux output? I *KNOW* I can do it with popen if it would just take data on stdin like any normal Un*x program. :-( :-( :-( I tried in the shell to use and and whatnot, but it didn't seem to like that... Does popen add any inherent ability to shove data to it via |, even if it's expecting a file?... How? Did I just not get the right magical combination of |? I grok | okay, and even , but as soon as you start using , I get lost for some reason... Long version: Suppose, hypothetically speaking, the following: Vendor provides a binary for talking to their credit-card processing center. Vendor provides PHP API script for accessing above binary. Said script boils down to this algorithm: Dump credit card info into $TEMP file. exec(binary ALLSTDIN $TEMP); unlink($TEMP); Now, granted, this is on an SSL server, and there shouldn't be any random users with access, and the files in question are being done via suExec, so it's not like they are world-readable... But *STILL*, I'm concerned about files sitting around on the hard drive with cc#s in them. What if somebody *DOES* break in and gets the suExec users's password somehow? What if they find and start reading those files? What if they don't get as far as that user's password, but they start resurrecting recently unallocated blocks from the hard drive? I just don't like the idea of storing credit card numbers on my web-site's hard drive, no matter how briefly. (And when their server is down or slow, it ain't gonna be all that brief...) Now I know that you can convert to popen() if the binary in question will take data from stdin. But the binary in question does not, at least from my lame attempts in a command shell. OTOH maybe that ALLSTDIN arg needs to change to something else to use stdin instead of a file... Though I would expect ALLSTDIN would be the keyword for data to come on stdin, not from a file, so I can't even *begin* to guess what keyword means ALLSTDINEVENTHECREDITCARDNUMBER... I've already emailed the vendor, but I'd just as soon patch their PHP API software as wait for their response, if there's some combination that works and doesn't just move the exposure to ps auxwww instead of the hard drive. They've got 200-page manuals about their API and their product and everything else that's not rocket-science, but nothing I can find about the actual binary and --help and -h don't put out usage prompts or anything standard like that :-( I even tried to run strings on it, in the hope of finding some nugget of info, but it wasn't particularly useful to somebody as dumb as me. I have had luck in the past with strings printing out the help itself (along with a lot of other crap) so I guess I'm not totally stupid to figure that one out, but no go this time. -- WARNING [EMAIL PROTECTED] email address is an endangered species Use [EMAIL PROTECTED] instead -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] popen returns true whether script exists or not?
Hi, I'm trying to popen a cgi script that was designed to be open via a SSI include, but cannot because of passing variable restrictions. I'm popening a cgi script and it is returning a process pointer regardless of whether the string passed to it points to anything. Is this the expected response? ? $p = popen( /web/guide/myfiles/bannerz.cgi,r ); ? this returns a process pointer even though bannerz.cgi doesn't exist I then need to read the results of the cgi script and dump them to the screen like so; ? while (!feof ($p)) { $buffer = fgets($p, 4096); echo $buffer; } pclose ($p); ? but this is not functioning, does anyone have any ideas? Regards Tom Hodder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] popen in safe_mode with pipe
Hello, I need to encode some text using GPG in a PHP program. I've a class wich uses popen like this: //--- start --- // parameters to gpg omited... $command = "echo '$text' | gpg snip"; $fd = popen("$command","r") if (!$fd) { return -2; } $enc = ""; while (!feof($fd)) { $enc .= fgets($fd,4096); } pclose($fd); //--- end --- That's with PHP4. It works ok in non-safe-mode, but with safe-mode turned on it doesn't. I'd like to use safe mode. Does anyone know a better (or correct) way to open this kind of pipe under safe_mode? (I've read a comment in the manual telling about opening the pipe for read-write mode, but it seems not to work wit the echo stuff in the first part of the command). Thank you. Rodolfo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]