A command such as "sudo echo mem >/sys/power/state" causes the command "sudo echo mem" to be executed, and its output redirected to /sys/power/state.
If you read the above carefully, you'll realize that the redirection does *not* happen as root: "echo mem" is executed as root, because sudo does that, but the redirection is done by the shell.
You probably want something like
sudo -c sh "echo mem >/sys/power/state"
A command such as "sudo echo mem >/sys/power/state" causes the command "sudo echo mem" to be executed, and its output redirected to /sys/power/state.
If you read the above carefully, you'll realize that the redirection does *not* happen as root: "echo mem" is executed as root, because sudo does that, but the redirection is done by the shell.
You probably want something like
sudo -c sh "echo mem >/sys/power/state"