Skip to content

Instantly share code, notes, and snippets.

@rjsalts
Created May 1, 2014 06:51
Show Gist options
  • Save rjsalts/46399174448f4a4eb9c2 to your computer and use it in GitHub Desktop.
Save rjsalts/46399174448f4a4eb9c2 to your computer and use it in GitHub Desktop.
#!/usr/bin/php
<?php
$fdspec = array(
0 => array( "pipe", "r" ),
1 => array( "pipe", "w" ),
2 => array( "pipe", "w" ),
);
$proc = proc_open("ls",$fdspec,$pipes,NULL,array());
if (is_resource($proc)) {
fclose($pipes[0]);
while(!feof($pipes[1])) {
static $line;
$prev_line = $line;
$line = stream_get_line($pipes[1],4096,"\n");
}
print $prev_line;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment