1

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.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Raulp
  • 7,758
  • 20
  • 93
  • 155

2 Answers2

4

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 
Don Chakkappan
  • 7,397
  • 5
  • 44
  • 59
  • any comment on this : http://stackoverflow.com/questions/29746538/android-running-two-application-script-with-a-reboot-in-between-without-manual – Raulp Apr 20 '15 at 11:27
  • Ar yeah! We need `sh` in front of the shell script. May I ask why we need `sh`? – midnite May 06 '22 at 13:51
2

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