PHP: Passing Arguments from Bash To PHP

Resources:

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";
    }
  
Tags