我已经编写了一个bash脚本以使用shell_exec()进行调用,并且只能以这种方式完成。但是,bash和浏览器均执行脚本。我试图弄清楚我错过了什么。
#!/usr/bin/php
<?php
require_once '../classpath.php';
require_once LIB_PATH.'Parser.php';
require_once LIB_PATH.'Save.php';
include FUNCTION_PATH.'multi_download.php';
$save = new Save();
$save->setFolder(CACHE_VIDEO_PATH);
$parser = new Parser($argv[1]);
$basename = $parser->bytag('/cast/stream/video/','.ts')[1];
array_shift($basename);
for($i= 0;$i<sizeof($basename);$i++){
//echo CACHE_VIDEO_PATH.'/'.$basename[$i].'.ts';
if(!$save->checkFile(CACHE_VIDEO_PATH.'/'.$basename[$i].'.ts'))
$basename[$i] = SERVER_URL.$basename[$i].'.ts';
else
array_splice($basename,$i,$i);
}
答案 0 :(得分:0)
#!/usr/bin/php
<?php
/* If it is not cli mode, do not execute the rest */
if (!php_sapi_name() == "cli")
die();
require_once '../classpath.php';
require_once LIB_PATH.'Parser.php';
require_once LIB_PATH.'Save.php';
include FUNCTION_PATH.'multi_download.php';
$save = new Save();
$save->setFolder(CACHE_VIDEO_PATH);
$parser = new Parser($argv[1]);
$basename = $parser->bytag('/cast/stream/video/','.ts')[1];
array_shift($basename);
for($i= 0;$i<sizeof($basename);$i++){
//echo CACHE_VIDEO_PATH.'/'.$basename[$i].'.ts';
if(!$save->checkFile(CACHE_VIDEO_PATH.'/'.$basename[$i].'.ts'))
$basename[$i] = SERVER_URL.$basename[$i].'.ts';
else
array_splice($basename,$i,$i);
}
请先进行研究,然后再提出问题,您可能需要阅读有关php cli的信息。 PHP Bash Script Executed in Browser