473,654 Members | 3,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

proc_open with pipes

62 New Member
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 1499

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

Similar topics

0
5841
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 $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child
0
2286
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 to be the right thing to use but I have the problem that the called program gives >8kb data on both stdout/stderr back which causes my PHP script to simply hang in the fread call. To be precise the first 4096 "O" characters are read and displayed. ...
0
1666
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 from the php website which looks something like copied below... Since I can not find very good documentation on this function my question is: I suppose that the problem is with this 2 => array("file", "error-output.txt", "w") // stderr is a file...
2
2894
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 segment prot after reloc: Permission denied" Im running php 4.3.11 on fedora 3. Here is the method i've been debugging. It should just run '/usr/bin/gpg --version' and display the
1
2302
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 => array("pipe", "r"),
2
4033
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 returns a successful exit value, and I can read the results it prints to STDOUT in PHP, but the perl script does not see STDIN from PHP. Since I want to use the perl script as a filter and I don't want to create an intermediary file, this is problematic....
0
1355
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 server-side component (written in C) that 'listens' for PHP requests (via its stdin) and spits out the appropriate response (via its stdout). Conversely, the PHP side uses fwrite() to send to the component's stdin and fread() to read from the component's...
5
3100
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
5470
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 22050 -y /home/transla1/public_html/cybertube/web/uploads/video/ generated/31_70_AK000005.AVI.flv '; //exec($str); runExternal($str,$code); echo $code ;
1
6259
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 http://stackoverflow.com/questions/196771/what-is-the-best-way-to-escape-python-strings-in-php when i made following py script. print 'enter value' input = raw_input() print input
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8482
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.