I have a little script that I'm trying to run but it dies at exec()
<pre><?php
ini_set("display_errors", 1);
$command = "wget --save-cookies cookies.txt \
--post-data '***' \
--keep-session-cookies \
http://site.com/ac_login.php;
wget --load-cookies cookies.txt \
--keep-session-cookies \
-p http://site.com/ac_landing.php;";
exec($command, $output) or die('fail');
foreach ($output as $num => $line) {
echo $num + 1 . ": " . $line . "\n";
}
?></pre>
If I remove the \
at the end of each line I get a response of
1: wget: missing URL
2: Usage: wget [OPTION]... [URL]...
3:
4: Try `wget --help' for more options.
5: wget: missing URL
6: Usage: wget [OPTION]... [URL]...
7:
8: Try `wget --help' for more options.
I tried moving all the commands to one line but then it dies again. What am I doing wrong? How can I retrieve the error in this script? Adding in a 3rd param for result in exec
returns empty.
I'm using this for reference https://stackoverflow.com/a/1432161/763468
The commands work in an SSH console.
die
Steve Robbins 2012-04-03 21:43
First off, I don't think you need that semi-colon after the file name
-p http://site.com/ac_landing.php;
to
-p http://site.com/ac_landing.php
Did you try one command per exec
call?
exec("wget --save-cookies cookies.txt --post-data '***' --keep-session-cookies http://site.com/ac_login.php");
exec("wget --load-cookies cookies.txt --keep-session-cookies -p http://site.com/ac_landing.php");