Is it possible to create a plugin, that can execute servercommands?

I don't mean minecraft commands, I mean commands for the system, like Linux and Windows.

In C++ the function is system().
I'm sorry if I failed to see a plugin that already exists,
Juli
:P
Yes, that should be very easy to create.

In fact, I just did it in under 5 minutes:
function Initialize(a_Plugin)
a_Plugin:SetName("Shell Execute")
a_Plugin:SetVersion(0)
LOG("Shell Execute is initialized");
cPluginManager:BindCommand("/shell", "shell.execute", HandleShellCommand, "Executes the given shell command")
return true
end
function HandleShellCommand(a_Split, a_Player)
local ShellCommand = table.concat(a_Split, " ", 2)
local res = assert(io.popen(ShellCommand)):read("*all")
a_Player:SendMessage(res)
return true
end
Just pop that in "root/Plugins/ShellExecute/main.lua" or something and enable it

I believe io.popen had some problems with Linux though.
(12-21-2015, 08:39 PM)NiLSPACE Wrote: [ -> ]I believe io.popen had some problems with Linux though.
Thank you for the fast answer, but like you write, it crashes a little bit in Linux...

Can I do anything to make it working?
Juli
Could you give me the error message?
(12-21-2015, 08:55 PM)NiLSPACE Wrote: [ -> ]Could you give me the error message?
[12:00:40] Deadlock detected, aborting the server
[12:00:40] D: | Cuberite has encountered an error and needs to close
[12:00:40] Details | SIGABRT: Server self-terminated due to an internal fault
[12:00:40] Cuberite Jenkins clang x64 Release (master) build id: #320
[12:00:40] from commit id: a99c82323e310c883876a51f8fac3e075d87540d built at: Fri 18 Dec 17:08:04 CET 2015
./Cuberite(_Z15PrintStackTracev+0x19)[0x5e3329]
./Cuberite(_Z14NonCtrlHandleri+0xe5)[0x5cd0f5]
/lib/x86_64-linux-gnu/libc.so.6(+0x352f0)[0x7f06a771e2f0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37)[0x7f06a771e267]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f06a771feca]
./Cuberite[0x559ce2]
./Cuberite[0x559d75]
./Cuberite(_ZN5cRoot12ForEachWorldER13cItemCallbackI6cWorldE+0x3d)[0x59423d]
./Cuberite(_ZN15cDeadlockDetect7ExecuteEv+0x3c)[0x559bbc]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xb9030)[0x7f06a7d83030]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76aa)[0x7f06a80536aa]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f06a77efeed]
It happends some seconds after I execute this command as Admin in the game.
I knew io.popen is sometimes weird on Linux, but I didn't know it would create a deadlock :/ The command you're trying to execute, does it terminate quickly afterwards, or will it always be active? If it's always active perhaps try to put a "&" after it. (<whatever command> &). In windows try putting "start /b" in front (start /b <whatever command>)
(12-21-2015, 09:11 PM)NiLSPACE Wrote: [ -> ]I knew io.popen is sometimes weird on Linux, but I didn't know it would create a deadlock :/ The command you're trying to execute, does it terminate quickly afterwards, or will it always be active? If it's always active perhaps try to put a "&" after it. (<whatever command> &). In windows try putting "start /b" in front (start /b <whatever command>)
Thank you for the answer!

After I entered the command, I don't receive any reaction, until the server crashed with that error message.

The & char doesn't change anything, but maybe it's possible to find an alternative.
Is it posssible to create a empty file with a specific name? I could create a backround process, that checks the avaibility (correct english word?) of the file and reacts then.

Hmm, I'm not sure if that would work. Question, do you want the output of the command to be send to the player? If not then you can change "local res = assert(io.popen(ShellCommand)):read("*all")" into "os.execute(ShellCommand)" with "&" or "start /b"
(12-21-2015, 09:23 PM)NiLSPACE Wrote: [ -> ]Hmm, I'm not sure if that would work. Question, do you want the output of the command to be send to the player? If not then you can change "local res = assert(io.popen(ShellCommand)):read("*all")" into "os.execute(ShellCommand)" with "&" or "start /b"
I don't need any output, so I changed the line, but the error doesn't dissapears

That's strange. Perhaps others know what the problem is, because I have no idea
