how to make PHP lists all Linux Users?

前端 未结 4 1598
轮回少年
轮回少年 2020-12-20 02:04

I want to build a php based site that (automate) some commands on my Ubuntu Server

first thing I did was going to the file (sudoers) and add the user www-data so I c

4条回答
  •  死守一世寂寞
    2020-12-20 02:50

    From the PHP manual on exec:

    Return Values

    The last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function. To get the output of the executed command, be sure to set and use the output parameter.

    So you have to do something similar to this:

    '.$command."
    "; exec($command, &$output); echo implode("
    \n", $output); ?>

提交回复
热议问题