Questions tagged [proc-open]

158 questions
16
votes
2 answers

how to get output of proc_open()

I've tried to get output from proc_open method in php, but, when I print it, I got empty. $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("file", "files/temp/error-output.txt", "a") ); $process =…
Bobby Stenly
  • 1,260
  • 3
  • 13
  • 23
9
votes
4 answers

Proper shell execution in PHP

The problem I was using a function that made use of proc_open() to invoke shell commands. It seems the way I was doing STDIO was wrong and sometimes caused PHP or the target command to lock up. This is the original code: function execute($cmd,…
Christian
  • 27,509
  • 17
  • 111
  • 155
9
votes
1 answer

Why does PHP hang after writing 4096 bytes to a process started with proc_open?

For anyone wondering, after leaving it all for a couple hours it now works perfectly. I'm trying to pass a video file to VLC using PHP as a proof of concept for an upcoming project proposal for someone. I've managed to show it works by creating a…
8
votes
3 answers

PHP proc_open opens multiple times

I have a utility function used for executing a program through CLI (cmd, bash etc). It returns an array of 3 items: STDOUT, STDERR and EXIT CODE. So far, it's been working nicely without issues. In fact, the problem I have with it doesn't really…
Christian
  • 27,509
  • 17
  • 111
  • 155
7
votes
1 answer

Use PHP's proc_open + bypass_shell to run an executable in the background AND retrieve the correct PID?

So, In PHP on Windows: is it possible to both run an executable in the background AND retrieve its PID? I've deduced that it's possible to accomplish both tasks separately, but not together. Backgrounding the Process To background a process launched…
leoj
  • 1,307
  • 10
  • 20
7
votes
2 answers

Reading from STDIN pipe when using proc_open

I am trying to make a website where people can compile and run their code online, thus we need to find an interactive way for users to send instructions. Actually, what first comes to mind is exec() or system(), but when users want to input sth,…
dahui
  • 115
  • 1
  • 8
7
votes
2 answers

fclose(): 18 is not a valid stream resource

I am trying to execute a process using proc_open. The I/O for the process is handled by the pipes !! $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w") ); Now, as it happens, sometimes the…
Kapil Kaushik
  • 1,536
  • 4
  • 21
  • 28
7
votes
2 answers

proc_open: Extending file descriptor numbers to enable "status" feedback from a Perl script

PHP's proc_open manual states: The file descriptor numbers are not limited to 0, 1 and 2 - you may specify any valid file descriptor number and it will be passed to the child process. This allows your script to interoperate with other scripts that…
Ricalsin
  • 950
  • 9
  • 28
6
votes
1 answer

PHP proc_open won't work - gives me "Missing handle qualifier in array"

Warning: proc_open(): Missing handle qualifier in array in C:\...\updatedots.php on line 102 I'm trying to open notepad the close it after 2 seconds. This is my code: $descriptorspec = array( 0 => array("pipe" => "r"), 1 => array("pipe" =>…
Hubro
  • 56,214
  • 69
  • 228
  • 381
6
votes
5 answers

How can I spawn concurrent processes with PHP?

I'm trying to spawn multiple processes at once in PHP with proc_open, but the second call won't start until the first process has ended. Here's the code I'm using: for ($i = 0; $i < 2; $i++) { $cmdline = "sleep 5"; print $cmdline . "\n"; …
Dan Goldstein
  • 23,436
  • 10
  • 47
  • 51
5
votes
2 answers

Composer - PHP Warning: proc_open(): fork failed - Cannot allocate memory

I have a problem with composer, it has always worked well but now it doesn't want to... Here is the result of a simple composer install command : bob@SRV04:~/testdir$ composer install Loading composer repositories with package information Updating…
arno
  • 792
  • 14
  • 33
5
votes
1 answer

Why are exec and proc_open running under different user on IIS?

I'm running my site on Windows Server 2012 R2 and IIS 8.5 and I encountered a problem. When I run exec('whoami'), it returns nt authority\iusr. When I run proc_open('whoami', $desc, $pipes), the result is iis apppool\mysite. Why is this happening?
Jan Voráček
  • 312
  • 2
  • 8
5
votes
1 answer

proc_open hangs when trying to read from a stream

I've encountered the issue with proc_open on Windows, when trying to convert a wmv file (to flv), using ffmpeg, however I suspect I'll encounter the same scenario whenever certain conditions occur. Basically my code is as follows: $descriptorspec =…
eithed
  • 3,933
  • 6
  • 40
  • 60
5
votes
1 answer

PHP: trying to get fgets() to trigger both on CRLF, CR and LF

I'm reading streams in PHP, using proc_open and fgets($stdout), trying to get every line as it comes in. Many linux programs (package managers, wget, rsync) just use a CR (carriage return) character for lines which periodically updates "in place",…
okdewit
  • 2,406
  • 1
  • 27
  • 32
4
votes
1 answer

Not getting entire response from popen

Hi I'm running a process with popen;- $handle = popen('python scriptos.py', "r"); while (!feof($handle)) { $data = fgets($handle); echo "> ".$data; } And I'm only getting 3 lines from a process that returns 5 lines. I run this exact command…
waxical
  • 3,826
  • 8
  • 45
  • 69
1
2 3
10 11