proc-open

Run perl file from PHP script but not wait for output on Windows Server

时光总嘲笑我的痴心妄想 提交于 2019-12-08 06:45:47
问题 Im trying to execute a perl script from within a php script. I have had this working using various methods such as exec, popen and proc_open but I have a couple of issues to get around which the good old Google isnt giving me the answers to. I need to run the .pl script (passing one variable to the script which is a number) from within the php file but stop the php script from waiting until the .pl has finished (the .pl is likely to take 4-5 hours to run on the server). Im not expecting any

Get PHP proc_open() to read a PhantomJS stream for as long as png is created

末鹿安然 提交于 2019-12-08 03:52:59
问题 I had a PHP script that relied on shell_exec() and (as a result) worked 99% of the time. The script executed a PhantomJS script that produced an image file. Then using more PHP that image file was processed in a certain way. Problem was that on occasion shell_exec() would hang and cause usability issues. Reading this https://github.com/ariya/phantomjs/issues/11463 I learnt that shell_exec() is the problem and switching to proc_open would solve the hanging. The problem is that while shell_exec

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

白昼怎懂夜的黑 提交于 2019-12-06 00:34:42
问题 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" => "w"), 2 => array("file" => "logs/errors.txt") ); // Create child and start process $child = array("process" => null, "pipes" => array()); $child["process"] = proc_open("notepad.exe > nul 2>&1", $descriptorspec, $child["pipes"]); Any idea what this error

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

微笑、不失礼 提交于 2019-12-04 06:38:05
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" => "w"), 2 => array("file" => "logs/errors.txt") ); // Create child and start process $child = array("process" => null, "pipes" => array()); $child["process"] = proc_open("notepad.exe > nul 2>&1", $descriptorspec, $child["pipes"]); Any idea what this error means and what causes it? It is not 0 => array("pipe" => "r") but 0 => array("pipe", "r") ^^ Additionally,

how to get output of proc_open()

谁都会走 提交于 2019-11-30 12:26:14
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 = proc_open("time ./a a.out", $descriptorspec, $pipes, $cwd); as long as I know, I can get the output with stream_get_contents() echo stream_get_contents($pipes[1]); fclose($pipes[1]); But I can't do that.. any suggestion? Thx before... Your code more or less works for me. time prints its output to stderr so if you're looking for that output, look in your file files

Reading from STDIN pipe when using proc_open

杀马特。学长 韩版系。学妹 提交于 2019-11-30 07:24:59
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, this way won't work. So we have to use proc_open() . For instance, the following code int main() { int a; printf("please input a integer\n"); scanf("%d", &a); printf("Hello World %d!\n", a); return 0; } When I used proc_open() , like this $descriptorspec = array( 0 => array( 'pipe' , 'r' ) , 1 => array( 'pipe' , 'w' ) , 2 => array( 'file' , 'errors' ,

Reading from STDIN pipe when using proc_open

流过昼夜 提交于 2019-11-29 09:33:27
问题 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, this way won't work. So we have to use proc_open() . For instance, the following code int main() { int a; printf("please input a integer\n"); scanf("%d", &a); printf("Hello World %d!\n", a); return 0; } When I used proc_open() , like this

proc_open interaction

送分小仙女□ 提交于 2019-11-27 15:23:20
Here's what I'm trying to achieve: open a shell (korn or bash, doesn't matter), from that shell, I want to open a ssh connection ( ssh user@host ). At some point it is likely to happen I will be prompted for either a password or I might be asked whether or not I'm sure I want to connect (offending keys). Before anyone asks: yes, I am aware there is a plugin for ssh2 exec calls, but the servers I'm working on don't support it, and are unlikely to do so. Here's what I've tried so far: $desc = array(array('pipe','r'),array('pipe','w'));//used in all example code $p = proc_open('ssh user@host',

load .profile with proc_open()

风流意气都作罢 提交于 2019-11-27 09:21:22
Here's the situation: I wrote a back end application, that runs on a certain server. On this server, there is a script that can be executed from the front end server, over ssh. My script will then check to see if the environment variables it needs are loaded correctly because I rely heavily on them in the script itself. This works, although not the way I want things to work. As the connection is established, the ./profile isn't loaded just using exec('source /home/user/.profile'); doesn't work, of course. Since the script is already running. That's why the script starts like this: #!/to/php

proc_open interaction

一笑奈何 提交于 2019-11-26 17:12:10
问题 Here's what I'm trying to achieve: open a shell (korn or bash, doesn't matter), from that shell, I want to open a ssh connection ( ssh user@host ). At some point it is likely to happen I will be prompted for either a password or I might be asked whether or not I'm sure I want to connect (offending keys). Before anyone asks: yes, I am aware there is a plugin for ssh2 exec calls, but the servers I'm working on don't support it, and are unlikely to do so. Here's what I've tried so far: $desc =