Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exec not found #915

Closed
androidealp opened this issue Jun 23, 2013 · 2 comments
Closed

exec not found #915

androidealp opened this issue Jun 23, 2013 · 2 comments

Comments

@androidealp
Copy link

@androidealp androidealp commented Jun 23, 2013

I got an error:
http://www.samba33.com/teste/teste.php

My python version is 2.6.6.
I update new version youtube-dl "youtube-dl -U"

I try this script:

<?php 
    $url = "http://www.youtube.com/watch?v=coq9klG41R8";
    $template = 'youtube-dl "'.$url.'" -f 18 -o "/var/www/vhosts/samba33.com/httpdocs/teste/%(id)s.%(ext)s"';
    exec($template);

    $string = ('youtube-dl ' . escapeshellarg($url) . ' -f 18 -o ' .
          escapeshellarg($template));

    $descriptorspec = array(
   0 => array("pipe", "r"),  // stdin
   1 => array("pipe", "w"),  // stdout
   2 => array("pipe", "w"),  // stderr
);
    $process = proc_open($string, $descriptorspec, $pipes);

    $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' => $string));
?>

Could you help me to identify the error?

@phihag
Copy link
Contributor

@phihag phihag commented Jun 23, 2013

It looks like youtube-dl is not in the PATH of your web user's account. Type which youtube-dl to find out where the binary is installed, and env to see the environment variables.

You can either fix the path (by modifying the PATH environment variable for the webserver user), or use the complete path (i.e.

$string = 'python /PATH/GOES/HERE/youtube-dl ' . escapeshellarg($url) . ' - f 18 -o ' . escapeshellarg(template);

or download youtube-dl into the local directory, and then call the local version

$string = 'python ./youtube-dl ' . escapeshellarg($url) . ' - f 18 -o ' . escapeshellarg(template);

By the way, you should either use exec or proc_open - otherwise, you'd call youtube-dl twice.

I'm closing this issue now since any of the above solutions should fix it. You are however more than welcome to comment, both if it works and if it doesn't. We'll open the issue then if necessary.

@phihag phihag closed this Jun 23, 2013
@androidealp
Copy link
Author

@androidealp androidealp commented Jun 24, 2013

Thank you for your help!
It worked very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.