1

I need to make a static page from the dynamic one with all assets downloaded and all the links converted to local ones and download it in some tmp folder. Like when you press Ctrl+S in a browser. I tried using wget with shell_exec:

shell_exec("wget -E -H -k -p http://youmightnotneedjquery.com/  2>&1");

The problem is that it works perfectly when I run it from console, but when I use shell_exec, I get an error

Permission denied youmightnotneedjquery.com/index.html: No such file or directory Cannot write to 'youmightnotneedjquery.com/index.html' (No such file or directory).

As I understand, there is some problem with permissions, I tried to create a seperate directory with some high permissions and www-data as owner and specify it in the command using -O flag, but I get an error that I can't use -k and -O flags at the same time. So I hope to solve that issue with permission, but I still have to specify the destination folder somehow. Or maybe there's a php solution without wget that I can use, as it seems not quite hard but a lot of work to do.

Dmytro Duplyka
  • 332
  • 2
  • 14

2 Answers2

0

You may try something like shell_exec("cd some_nice_dir && wget ...")

You may also want to read up on man wget as it has a lot to say about interferences between -O and several of the other options you specify.

Hagen von Eitzen
  • 2,109
  • 21
  • 25
0

Helped using -P flag and creating a folder with owned www-data

shell_exec("wget -E -H -k -p http://mysite.local/ -P some-temp-folder 2>&1")
Dmytro Duplyka
  • 332
  • 2
  • 14