Redirections such as
|are performed by the running shell, before it invokes
You have to either use
sudo sh -c "echo blah > /proc/blah", or run a root shell with
This had me stumped until the greatness of google divined the answer and why my user script couldn’t write to a root owned file using plain old sudo. After figuring this out I also realized I don’t need to write to a root owned file after all but I found this solution interesting.