How to execute commands, after exiting ADB shell? I'm coding a script to automate an application configuration export process.
adb shell
...
&lt;open app menu&gt;
&lt;open app settings&gt;
&lt;save app backup&gt;
...
exit

The problem is: after saving the backup I want to pull the file to my computer, using this:
adb pull /storage/emulated/0/Backups/ ~/Documents/phone

Although, I can't figure out how to execute this command, after exiting adb shell. It seems like commands after exit are ignored:
adb shell
...
&lt;open app menu&gt;
&lt;open app settings&gt;
&lt;save app backup&gt;
...
exit
adb pull /storage/emulated/0/Backups/ ~/Documents/phone

Maybe, this is an issue I should addres to the &quot;Unix &amp; Linux&quot; community, but I decided to try here first.
Write your script a little different:
#!/bin/bash
adb shell &lt;&lt;EOF
...
&lt;open app menu&gt;
&lt;open app settings&gt;
&lt;save app backup&gt;
...

EOF

adb pull /storage/emulated/0/Backups/ ~/Documents/phone

All between &lt;&lt;EOF and the EOF standing separately at the start of its own line is run in adb shell, all outside is run on your local machine. Note: no exit needed.