Resources:
- https://www.php.net/manual/en/reserved.variables.argv.php
- https://www.php.net/parse_str
- https://stackoverflow.com/questions/6779576/how-to-pass-parameters-from-bash-to-php-script#6779733
Shell
echo "Testing destination dir -" $ytuDest
PHP Main
/*
* Start of PHP CLI Script
*/
//require_once '/home/silosix/git/phpunitwebdriver/src/Shell/YtdlWrapper.php';
//require_once '../Shell/YtdlWrapper.php';
print "Downloading YT Videos: START"."\n";
print "parsing arguments"."\n";
parse_str($argv[2],$output);
var_dump($argv);
var_dump($output);
$ytuDest = $output['ytuDest'];
print "ytuDest=" . $ytuDest."\n";
// test if/then with this
// $ytuDest="";
if ($ytuDest=="" || $ytuDest==null) {
print "ytuDest is not assigned, using ~/Videos"."\n";
$ytuDest="~/Videos";
}
$obj = new YtdlApp($ytuDest);
PHP Class
class YtdlApp
{
private $filename; // = "/home/silosix/scripts/url.txt";
public $ytuDest;
function __construct(string $dest){
$this->ytuDest = $dest;
print "ytuDest=".$dest."\n";
print "ytuDest=".$this->ytuDest."\n";
}
- Log in to post comments
