Issues with exec and wget

I am very confused. This is my code

<?php
exec('touch zzzzz.txt');
exec('wget --output-document html-dir.lst --output-file wget.log --http-user USERNAME --http-passwd PASSWD https://SOME WEB SITE/');
exec('wget --http-user USERNAME --http-passwd PASSWD https://SOME WEB SITE/');

?>

The first and last “exec” work as expected but it’s the middle one I need to work.
Originally I was using -O and -o but when I got the 3rd line to work I assumed the short versions where causing the issue, of course that was not the case. This makes no sense to me I’ve been at it for days !
What is wrong with the second exec! Of course I comment one or the other out when running tests.
Neither html-dir.lst or wget.log are created.

I can copy and paste the command between the single quotes into bash and it works perfectly.

exec('wget --output-document html-dir.lst --output-file wget.log --http-user USERNAME --http-passwd PASSWD https://SOME WEB SITE/');

The lines below work now from the web site as expected.

$eline = rawurlencode($line);
$doit = "wget --http-user USERNAME --http-passwd PASSWD https://SOME WEB SITE/".$eline." --output-document \"/media/henrywho/ARCH-tmp/ZZ-NEW/".$line."\"";
exec ($doit);

The thing that made the difference was moving the “–output-document html-dir.lst” after the URI.
Makes no diff in bash but huge diff in EXEC.
Why !

Sponsor our Newsletter | Privacy Policy | Terms of Service