Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a shell script in Android from the Host

Tags:

android

shell

adb

I have a Host development PC running Ubuntu and I am doing all the android development on it.From this PC I wanted to (adb) push some files(executables) to android filesystem (say /data/dir1) , cd into it and run that executable.Using a shell script (shown below) I can do this from the PC upto to connecting the android device and doing adb shell but I can not run other commands after that . e.g scripts

adb push <file1> /data/dir1/ 
adb shell
cd data/dir1
./file1

I can run upto adb shell but not beyond that.How can I achieve the remaining two commands ( changing the directory to data/dir1 and running the ./file1) from the shell script running on the Host PC.

like image 351
Raulp Avatar asked Mar 14 '26 15:03

Raulp


2 Answers

You

don't need to enter into the adb shell

, change the path and more.

You can accomplish everything in a single command , like

adb push my_script_file.sh  /data/dir1/ 

adb shell sh data/dir1/my_script_file.sh 
like image 93
Don Chakkappan Avatar answered Mar 16 '26 03:03

Don Chakkappan


1.first of all go the root by the command sudo -i

  1. write the program

adb shell ls data/dir1

3.execute it -./file by the above program you can move to the folder in the shell

like image 44
user14366417 Avatar answered Mar 16 '26 03:03

user14366417



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!