3

i have a simple script which im testing at the moment but it's not working.

I have this simple lines :

$url = "http://www.google.com";   
system("wget --page-requisites ".$url); 

The issue is that it does nothing, my website is located at /var/www/html/server_a which is where im checking if it downloaded the required page but seems like it's doing nothing.

Im using a VPS with Ubuntu 14.04

darnir
  • 4,870
  • 4
  • 32
  • 47
Gongas
  • 87
  • 7
  • Have you checked the permissions in the folder `/var/www/html/`? – Dalton Cézane Sep 03 '18 at 15:28
  • Can you check your error log, or alternatively turn error reporting on and see if it shows any warnings or errors? – SuperCabbage Sep 03 '18 at 15:52
  • Cannot write to 'www.example.com/index.html' (No such file or directory). Converted 0 files in 0 seconds. --2018-09-03 11:21:16-- http://www.google.com/ Resolving www.google.com (www.google.com)... 108.177.122.106, 108.177.122.147, 108.177.122.104, ... Connecting to www.google.com (www.google.com)|108.177.122.106|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html] www.google.com: Permission deniedwww.google.com/index.html: No such file or directory Cannot write to 'www.google.com/index.html' (No such file or directory). – Gongas Sep 03 '18 at 16:38
  • is /var/www/html/server_a owned by www-data:www-data? – unixmiah Sep 04 '18 at 12:57

1 Answers1

0

Your issue is sudo, you need to add sudo before you run this command.

$url = "http://www.google.com";   
system("sudo wget --page-requisites ".$url); 
unixmiah
  • 3,081
  • 1
  • 12
  • 26
  • That doesn't sound like a good idea. Why would wget require sudo? Why do you assume that his user account is capable of `sudo`ing? You'd have to additionally type a password in which `system()` isn't doing. – Xatenev Sep 04 '18 at 13:06
  • That's not going to work as your not sending the password. – Dave Carruthers Sep 04 '18 at 13:07
  • Hmn.. the user doesn't have enough permission. i wonder what is the alternative. – unixmiah Sep 04 '18 at 13:09
  • `system("echo password | sudo -S wget --page-requisites ".$url);` – Dave Carruthers Sep 04 '18 at 13:16
  • I already fixed this , there was no need for sudo as it would bring alot of security issues , so i simply added permissions to the folder of the website to which it could download the wget – Gongas Sep 04 '18 at 16:01