Pushing stuff into /dev/input is lower level than it need be.
You'll be working with scan codes there.
In a shell this sends a press of the power button (using a KEYCODE)
Shutdown is easy enough (with one small hitch).
Simply send a android.intent.action.ACTION_REQUEST_SHUTDOWN
The problem is that this is a privileged intent and can only be sent by system apps.
System apps are those that have the system signature.
You can do that by re-signing your system.
You need to have android.permission.SHUTDOWN in the manifest.