Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb shell running multiple commands from same cmd window

Tags:

android

adb

I am trying to create a Perl script to run set of commands through adb shell.

cmd1 
cmd2 
cmd3 
cmd3(1)

I put all the commands in a text file and ran it like this: adb shell < adb_commands.txt.(reference)

However, I have this one issue where the last command cmd3(1) needs to be executed from within the previous command cmd3.
So cmd3 will be executed and will wait for cmd3(1) to be entered. This is not happening coz as far as i can tell, adb shell is waiting for cmd3 to finish so it can run cmd3(1).

Can someone please advise on how to solve this issue or if there are any alternate ways to do this?

like image 265
bart mirage Avatar asked Oct 24 '25 03:10

bart mirage


2 Answers

You can execute multiple commands separated by && operator

adb shell "netcfg && ps && getprop"
like image 95
Rachit Agrawal Avatar answered Oct 27 '25 01:10

Rachit Agrawal


Use & not &&

&& run next command only if the previous were successful

& run next command after the previous finish no matter successful or not

like image 26
TheMaster Moh Avatar answered Oct 26 '25 23:10

TheMaster Moh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!