Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute command line via php?

How I can execute those two command line via php:

wkhtmltopdf www.google.com gg.pdf

&

oofice -headless -nologo -pt cup-pdf my.doc

they both return a pdf file and download into my home directory.

I want to know the way to execute those command from my html page via php.

Thanks.

like image 891
XS07 Avatar asked Jul 22 '11 22:07

XS07


2 Answers

You should take a look at the System program execution section of the manual : PHP provides several functions that can be used to launch external commands / programs, including :

  • exec() -- which can store the output of the command in an array
  • shell_exec() -- which returns, as a string, the output of the command
  • system() -- which echoes the output of the command
like image 133
Pascal MARTIN Avatar answered Oct 25 '22 14:10

Pascal MARTIN


To create a pdf from php(in linux) you must use a wrapper.

$cmd = '/usr/bin/xvfb-run --server-args="-screen 0, 1920x1080x24" /usr/bin/wkhtmltopdf http://google.com /tmp/google.pdf';

exec($cmd);
like image 34
The.Power.Process Avatar answered Oct 25 '22 15:10

The.Power.Process