php shell_exec touch redirect and adduser

后端 未结 2 1423
慢半拍i
慢半拍i 2021-01-21 16:15

I am trying to ultimately use php\'s shell_exec function to create new Linux users. I am, however, running into problems even with the debugging. Here is my code

2条回答
  •  [愿得一人]
    2021-01-21 17:04

    Please use my function found here.

    Run the following code and tell us its output:

    echo '
    ';
    print_r(execute('pwd'));
    print_r(execute('touch test.txt'));
    

    Edit: If you want to make my script more OO oriented:

    function execute_o($cmd,$in){
        $out=execute($cmd,$in);
        if($out['return']!=0)
            throw new Exception('Error '.$out['return'].': '.$out['stderr'].'.');
    }
    

提交回复
热议问题