Can android device issue adb commants to itself? I made a simple shell (actually windows batch) script that automates a task on android phone. It can be ran on any computer. I thought that if I convert the batch to linux sh script, I could issue the commands without adb shell before them.

So this (.exe added for clarity):

adb.exe shell sleep 1


becomes this:

sleep 1


Well it works with sleep in particular, but not with sendevent. I made a script to press and release focus button:

#!/bin/sh
# Simply send two key events to see if it works (spoiler: it doesn't)
sendevent /dev/input/event0 1 212 1
sendevent /dev/input/event0 0 0 0
sleep 1
sendevent /dev/input/event0 1 212 0
sendevent /dev/input/event0 0 0 0


But I cannot execute the sendevent commands:



That's ridiculous. Obviously my phone is capable of executing the commands from external source, so why the hell not from itself? Am I going to need a computer to work with the shell?

What can I do to issue adb commands to my own phone? (I am not using rooted device. Android developers made it too much painful to achieve.)
Adb is a two-part system, the "ADB" command that runs on your computer, and a daemon that runs on the device to receive the commands you send to it. 

To run it on the device you need a version of ADB that is compiled to run on the device. There are several of these on the play store (Search "Adb Shell") on Google Play, such as Adb Shell. 

There is also an "ADBLib" by Cameron Guzman on GitHub that can be compiled into an Android App and allow run Adb Shell commands from there.