Skip to content

Instantly share code, notes, and snippets.

@pricejn2
Created January 12, 2014 02:38
Show Gist options
  • Select an option

  • Save pricejn2/8380040 to your computer and use it in GitHub Desktop.

Select an option

Save pricejn2/8380040 to your computer and use it in GitHub Desktop.
script execution from php
// convert
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w"), // stderr
);
flush();
$process = proc_open($youtdl, $descriptorspec, $pipes);
if (is_resource($process)) {
while ($s = fgets($pipes[1])) {
print $s;
flush();
}
}
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$ret = proc_close($process);
// echo json_encode(array('status' => $ret, 'errors' => $stderr, 'url_orginal'=> $url, 'output' => $stdout, 'command' => $youtdl));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment