473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

proc_open with pipes

I don't know why the following script intermittently crashes when I remove the sleep() call. I believe the pipes were not properly set yet before the shell statement was called, which used pipes also. This is on Windows 98 (I know it's a bit old), with PHP 5.2.5, and tlist and findstr came from the resource toolkit (ftp://ftp.microsoft.com/services/tec...s/win98/reskit).

BTW I am trying to get the real PID of the process which was patched in version 5.3, but I would still want to know why the script completely fails (becomes unresponsive and cannot be killed).

Expand|Select|Wrap|Line Numbers
  1. <?
  2. if( strtolower(substr($argv[1],-4))!='.exe' ) $argv[1].='.exe';
  3. $p=proc_open($argv[1]
  4.     ,array(array('pipe','r'),array('pipe','w'),array('file','error.txt','a'))
  5.     ,$pipes);
  6. /*    ,null
  7.     ,null
  8.     ,array(array('bypass_shell',true)));*/
  9. if( is_resource($p) )
  10. {
  11.     print_r(proc_get_status($p));
  12.     sleep(1);
  13.     $str=shell_exec('tlist|findstr /i "'.$argv[1].'"');
  14.     echo "$str\n";
  15.     sscanf($str,'%d',$pid);
  16.     echo "PID: $pid\n";
  17.     $r=proc_close($p);
  18.     echo "<$r>\n";
  19. }
  20. ?>
  21.  
Jun 16 '09 #1
0 1481

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bernhard Kuemel | last post by:
Hi! I want to read/write commands and program input to/from /bin/bash several times before I close the stdin pipe. However, reading from cat hangs unless I first close the stdin pipe. <?php...
0
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems...
0
by: Muffinman | last post by:
Howdy, For a script I need the exact output of the apache htdbm.exe to a var so I can extract all users from a database. Now I found out that this can be done with Proc_open. I got this script...
2
by: razorfold | last post by:
Hi, I've been trying to run gpg through proc_open() and have failed all weekend. I keep getting this error from stderr: "/usr/bin/gpg: error while loading shared libraries: cannot restore...
1
by: arielCo | last post by:
Hello, I'm attempting to use proc_open to launch, control and log CLI applications from my scripts, but my first tests are disheartening: <pre> <?php $descriptorspec = array( 0 =>...
2
by: kimonp | last post by:
I am running on windows XP with a fresh install of wamp5 (1.7.2) and mediawiki. I am trying to call a perl function from within php using proc_open. The perl script is being executed and...
0
by: Daniel Klein | last post by:
Without getting into a lot of unnecessary detail, I'm working on a project to allow PHP to communicate with a proprietary database. The IPC mechanism I'm using is 'proc_open'; there is a...
5
by: sakismat | last post by:
please help how can I get stderr from processes ($proc) in my screen without waiting the other processes to end #!/usr/bin/php <?php $con = mysql_connect("localhost", "user"); if (!$con)
6
by: xhe | last post by:
I am using ffmpeg to convert video, this is a sample script: $str='/home/transla1/bin/ffmpeg -i /home/transla1/public_html/ cybertube/web/uploads/video/31_AK000005.AVI -s 240x180 -b 100k -ar...
1
by: YasirHussain | last post by:
hi! i want to execute a python script from php through proc_open() function of php.. i read a fine tutorial at ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.