docs
[mirrors/Programs.git] / php / mc
CommitLineData
8de51304
H
1#!/usr/bin/php
2<?php
3if($argc < 2) die("usage: pwrap command\n");
4for($i=1;$i<$argc;$i++) $command = $command.' '.$argv[$i];
5
6$descriptorspec = array(
7 0 => array("pipe", "r"), // stdout
8 1 => array("pipe", "w"), // stdin
9 //2 => array("pipe", "r") // stderr
10 //2 => array("file", "./error-output.txt", "a") // stderr is a file to write to
11);
12
13$cwd = '~/';
14
15$process = proc_open($command, $descriptorspec, $pipes, $cwd, $_ENV);
16$stdin = fopen('php://stdin', 'r');
17
18stream_set_blocking($pipes[0], 0);
19stream_set_blocking($pipes[1], 0);
20//stream_set_blocking($pipes[2], 0);
21stream_set_blocking($stdin, 0);
22
23while(!feof($pipes[0]) && !feof($pipes[1])) {
24 echo(fgetc($pipes[1]));
25 fwrite($pipes[0], fgetc($stdin));
26}
This page took 0.170491 seconds and 4 git commands to generate.