How to run linux command with php script

Possible duplicate:
php shell_exec () vs exec ()

How to run linux command with php script? I am running Linux Debian and PHP5. I want you to be able to send the wget command to the console.

An example of what I'm looking for looks something like this:

 phpFunction ("wget http://www.example.com/image.jpg /folder"); echo "done"; 

Also could I echo this function?

+7
source share
4 answers

Use exec to run any command. Be careful not to make any user input, as it can seriously undermine your server.

Also note that most shared servers block the exec function, so you cannot use it.

Finally, as a shorthand, you can wrap the command you want to run in backticks .

+11
source

You can do what you want with the following code:

 system(command); 

See http://php.net/system

+4
source

You can execute linux commands in php script - all you have to do is put the command line in brackets (`).

And also focus on exec() , this and shell_exec() ..

+3
source
0
source

All Articles