This code is able to fetch rednet messages and execute them as shell commands. You can edit this in any way. For example add a protocol to make sure your remote execution is secure. This program is invented by PwnCC.

local function update()
while true do
local event, senderId, msg, protocol = os.pullEvent("rednet_receive")
shell.run(msg)
rednet.broadcast()
end
end
end
parallel.waitForAny(update, function() shell.run("shell") end)