[MOD]Added [noparse]

...

[/noparse] tags.[/MOD][/i]

Hi,
I am trying to use unix wget in PHP.

 $url = 'http://www.google.com';
 $cmd = 'wget -nv -o output.txt -r -R jpg,gif -w1 '.$url;
 system($cmd);

Only the wget command is giving problems. When I tried other simple unix commands , they worked fine.

Instead of system I used shell_exec, passthru but none worked.

Any help is greatly appreciated.

Thnx in advance

    you aer sure wget is installed on your system?

      yes .. when I just typed the command in the unix shell it returns output.

        your not setting a return var so you wont get anything back from system.

          in above code , I am writing to a output file 'output.txt' . So when I run it , I think it should create an output.txt automatically with the contents of wget output ... doesn't it ??

            Check permissions on the directory where the file is to be written, as you PHP script is likely being executed under the web server's account and not your personal account.

            It might also be useful to ensure all error reporting is on and being displayed (or check the error logs) to see if PHP is complaining about anything.

              i gave full permissions to the directory .. and modified the system command as system($cmd, $retval) .. now when I print $retval it prints 1 which means the command failed to execute .. I have no clue why it does so.

              Also I cannot modify php.ini to turn all error reporting as it's on another machine .

                Write a Reply...