【问题标题】:Can't write to shared drive from PHP script (youtube-dl)无法从 PHP 脚本 (youtube-dl) 写入共享驱动器
【发布时间】:2014-12-18 08:50:32
【问题描述】:

我用过搜索-

我在 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));

【问题讨论】:

  • ls -la /windowshare 以 root 身份运行时的输出是什么?这听起来像是权限问题。
  • 嗨,总共 60498714 drwxr-xr-x 1 根 98304 12 月 14 日 05:01。 drwxrwxrwx 10 根 12288 12 月 18 日 19:30 .. -rwxr-xr-x 1 根 69870400 2011 年 11 月 17 日 -rwxr-xr-x 1 根 1346825 2007 年 10 月 8 日 -rwxr-xr-x 1 根 19491952 10 月 8 日2007 drwxr-xr-x 1 根 0 Apr 7 2014 -rwxr-xr-x 1 根 9662390 11 月 23 日 16:17 -rwxr-xr-x 1 根 3972200 11 月 12 日 15:13

标签: php youtube youtube-dl


【解决方案1】:

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

【讨论】:

  • 谢谢,我知道这是问题所在,但太混乱了,无法弄清楚......
  • same message..... 从根命令“php youtube-dl.php”可以正常工作,但不能从 httpd 内部通过浏览器将其拉到 http {"status":1,"errors": “错误:无法打开写入:[Errno 13] 权限被拒绝:
猜你喜欢
  • 2020-02-28
  • 1970-01-01
  • 1970-01-01
  • 2016-01-28
  • 2019-05-17
  • 2020-10-05
  • 2015-12-22
  • 2021-03-02
  • 1970-01-01
相关资源
最近更新 更多