Executing unix shell commands using PHP

前端 未结 7 619
再見小時候
再見小時候 2020-12-16 01:17

A text box will be used to capture the command. I\'ve been told that I have to use the exec() function to execute UNIX shell commands.

Something like th

7条回答
  •  孤城傲影
    2020-12-16 02:13

    Use $output = system($command);

    See http://php.net/system and don't forget to read the warnings about security. If you let a user pass any data to system() (or exec() etc.) it's almost as if they had a shell on your server. The same applies if you don't sanitize arguments passed to programs executed through these functions properly.

提交回复
热议问题