0

I have a .bat script with some adb commands that I want to run on a Mac. So I changed the extension to .sh and changed the mode so it's executable.

Every line works fine when I enter them in the macOS terminal, but when I run the .sh file errors would occur.

For example:

adb shell "echo 1 > xxxxx"

Results in:

Permission denied can't create xxxx: No such file or directory

When I try to push some file in the same directory as the script, it shows the status of the transmission like:

13.2 MB/s (525534 bytes in 0.038s) 

but then followed by:

No such file or directory
6
  • Can you access the adb shell prompt? adb shell Feb 14, 2019 at 3:17
  • @BlueDrink9 Thank you! I can access the adb shell in the terminal with no problem. :) When I change the script to .sh, looks like adb shell works fine too. But adb shell "echo 1 > xxx" does not work :( Feb 14, 2019 at 3:49
  • Can you try specifying an absolute path for the output? eg adb shell "echo test > /data/data/test.txt" Feb 14, 2019 at 3:51
  • @BlueDrink9 Thanks:) Sorry about the confusion. I've done that, I just sensored the names in this question lol. The exact command works fine when I enter them manually in the terminal of MacOS. Feb 14, 2019 at 3:56
  • Yes, that is because you have permission for the directory under OSX, but probably not in the phone directory. That is why using su worked. Feb 14, 2019 at 20:29

1 Answer 1

1

I've changed

adb shell "echo 1 > xxxxx"

to

adb shell "echo 1 > xxxxx" \| su

and it worked.

I've found the solution here: https://code.i-harness.com/en/q/85b288

2
  • Please edit your answer with the final command for clarity Feb 14, 2019 at 20:27
  • @BlueDrink9 Thanks :) I've edited the answer. Feb 15, 2019 at 12:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .