1

我已经使用了搜索 -

我在命令提示符下的 Windows 服务器上有一个共享驱动器,我可以在运行 youtube-dl 的驱动器上写入,但是从 PHP 脚本 - youtube-dl 说permission error ( no permission error on local drive)

如果我从命令提示符以 root 身份运行包含 youtube-dl 的 PHP 脚本,它工作正常。

下面是php脚本

echo "Saving $v";
$url = "http://www.youtube.com/watch?v=$v";
$template = '/windowshare/%(id)s.%(ext)s';
$string = ('youtube-dl ' . escapeshellarg($url) . ' -f 22 -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));
4

1 回答 1

0

这与 php 或 youtube-dl 无关 - 运行网络服务器的用户根本没有写入目标目录的权限。选择另一个目录或更改权限。例如,sudo chmod a+rw /windowshare以 root 身份运行以允许所有人写入目录。

于 2014-12-19T10:46:21.290 回答