php exec() is not executing the command

后端 未结 2 2135
后悔当初
后悔当初 2020-12-04 16:35

I have tried to use exec() with \'whoami\' to check if it works and I got the result of

nt authority\\system

Now

相关标签:
2条回答
  • 2020-12-04 17:08

    I already said that I was new to exec() function. After doing some more digging, I came upon 2>&1 which needs to be added at the end of command in exec().

    Thanks @mattosmat for pointing it out in the comments too. I did not try this at once because you said it is a Linux command, I am on Windows.

    So, what I have discovered, the command is actually executing in the back-end. That is why I could not see it actually running, which I was expecting to happen.

    For all of you, who had similar problem, my advise is to use that command. It will point out all the errors and also tell you info/details about execution.

    exec('some_command 2>&1', $output);
    print_r($output);  // to see the response to your command
    

    Thanks for all the help guys, I appreciate it ;)

    0 讨论(0)
  • 2020-12-04 17:34

    You might also try giving the full path to the binary you're trying to run. That solved my problem when trying to use ImageMagick.

    0 讨论(0)
提交回复
热议问题