The command “adb” not working as expected in a macOS shell script but works fine in the macOS terminal












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









share|improve this question

























  • Have you looked at this thread on Stack Overflow? You should also probably be renaming that file .sh instead of .command and the beginning of then script should have the line #!/bin/bash -l.

    – JakeGould
    Feb 14 at 3:05













  • Can you access the adb shell prompt? adb shell

    – BlueDrink9
    Feb 14 at 3:17











  • @JakeGould Thank you! I've changed it to .sh, now adb remount works, but the adb shell echo 1 > xxx still doesn't work. I've tried some other adb shell commands looks like there weren't any complains

    – user5815428
    Feb 14 at 3:46













  • @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 :(

    – user5815428
    Feb 14 at 3:49













  • Can you try specifying an absolute path for the output? eg adb shell "echo test > /data/data/test.txt"

    – BlueDrink9
    Feb 14 at 3:51
















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









share|improve this question

























  • Have you looked at this thread on Stack Overflow? You should also probably be renaming that file .sh instead of .command and the beginning of then script should have the line #!/bin/bash -l.

    – JakeGould
    Feb 14 at 3:05













  • Can you access the adb shell prompt? adb shell

    – BlueDrink9
    Feb 14 at 3:17











  • @JakeGould Thank you! I've changed it to .sh, now adb remount works, but the adb shell echo 1 > xxx still doesn't work. I've tried some other adb shell commands looks like there weren't any complains

    – user5815428
    Feb 14 at 3:46













  • @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 :(

    – user5815428
    Feb 14 at 3:49













  • Can you try specifying an absolute path for the output? eg adb shell "echo test > /data/data/test.txt"

    – BlueDrink9
    Feb 14 at 3:51














0












0








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









share|improve this question
















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






macos command-line batch-file adb






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 14 at 3:57







user5815428

















asked Feb 14 at 2:45









user5815428user5815428

114




114













  • Have you looked at this thread on Stack Overflow? You should also probably be renaming that file .sh instead of .command and the beginning of then script should have the line #!/bin/bash -l.

    – JakeGould
    Feb 14 at 3:05













  • Can you access the adb shell prompt? adb shell

    – BlueDrink9
    Feb 14 at 3:17











  • @JakeGould Thank you! I've changed it to .sh, now adb remount works, but the adb shell echo 1 > xxx still doesn't work. I've tried some other adb shell commands looks like there weren't any complains

    – user5815428
    Feb 14 at 3:46













  • @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 :(

    – user5815428
    Feb 14 at 3:49













  • Can you try specifying an absolute path for the output? eg adb shell "echo test > /data/data/test.txt"

    – BlueDrink9
    Feb 14 at 3:51



















  • Have you looked at this thread on Stack Overflow? You should also probably be renaming that file .sh instead of .command and the beginning of then script should have the line #!/bin/bash -l.

    – JakeGould
    Feb 14 at 3:05













  • Can you access the adb shell prompt? adb shell

    – BlueDrink9
    Feb 14 at 3:17











  • @JakeGould Thank you! I've changed it to .sh, now adb remount works, but the adb shell echo 1 > xxx still doesn't work. I've tried some other adb shell commands looks like there weren't any complains

    – user5815428
    Feb 14 at 3:46













  • @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 :(

    – user5815428
    Feb 14 at 3:49













  • Can you try specifying an absolute path for the output? eg adb shell "echo test > /data/data/test.txt"

    – BlueDrink9
    Feb 14 at 3:51

















Have you looked at this thread on Stack Overflow? You should also probably be renaming that file .sh instead of .command and the beginning of then script should have the line #!/bin/bash -l.

– JakeGould
Feb 14 at 3:05







Have you looked at this thread on Stack Overflow? You should also probably be renaming that file .sh instead of .command and the beginning of then script should have the line #!/bin/bash -l.

– JakeGould
Feb 14 at 3:05















Can you access the adb shell prompt? adb shell

– BlueDrink9
Feb 14 at 3:17





Can you access the adb shell prompt? adb shell

– BlueDrink9
Feb 14 at 3:17













@JakeGould Thank you! I've changed it to .sh, now adb remount works, but the adb shell echo 1 > xxx still doesn't work. I've tried some other adb shell commands looks like there weren't any complains

– user5815428
Feb 14 at 3:46







@JakeGould Thank you! I've changed it to .sh, now adb remount works, but the adb shell echo 1 > xxx still doesn't work. I've tried some other adb shell commands looks like there weren't any complains

– user5815428
Feb 14 at 3:46















@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 :(

– user5815428
Feb 14 at 3:49







@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 :(

– user5815428
Feb 14 at 3:49















Can you try specifying an absolute path for the output? eg adb shell "echo test > /data/data/test.txt"

– BlueDrink9
Feb 14 at 3:51





Can you try specifying an absolute path for the output? eg adb shell "echo test > /data/data/test.txt"

– BlueDrink9
Feb 14 at 3:51










1 Answer
1






active

oldest

votes


















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






share|improve this answer


























  • Please edit your answer with the final command for clarity

    – BlueDrink9
    Feb 14 at 20:27











  • @BlueDrink9 Thanks :) I've edited the answer.

    – user5815428
    Feb 15 at 12:06











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1405512%2fthe-command-adb-not-working-as-expected-in-a-macos-shell-script-but-works-fine%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









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






share|improve this answer


























  • Please edit your answer with the final command for clarity

    – BlueDrink9
    Feb 14 at 20:27











  • @BlueDrink9 Thanks :) I've edited the answer.

    – user5815428
    Feb 15 at 12:06
















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






share|improve this answer


























  • Please edit your answer with the final command for clarity

    – BlueDrink9
    Feb 14 at 20:27











  • @BlueDrink9 Thanks :) I've edited the answer.

    – user5815428
    Feb 15 at 12:06














1












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






share|improve this answer















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







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 15 at 12:04

























answered Feb 14 at 4:25









user5815428user5815428

114




114













  • Please edit your answer with the final command for clarity

    – BlueDrink9
    Feb 14 at 20:27











  • @BlueDrink9 Thanks :) I've edited the answer.

    – user5815428
    Feb 15 at 12:06



















  • Please edit your answer with the final command for clarity

    – BlueDrink9
    Feb 14 at 20:27











  • @BlueDrink9 Thanks :) I've edited the answer.

    – user5815428
    Feb 15 at 12:06

















Please edit your answer with the final command for clarity

– BlueDrink9
Feb 14 at 20:27





Please edit your answer with the final command for clarity

– BlueDrink9
Feb 14 at 20:27













@BlueDrink9 Thanks :) I've edited the answer.

– user5815428
Feb 15 at 12:06





@BlueDrink9 Thanks :) I've edited the answer.

– user5815428
Feb 15 at 12:06


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1405512%2fthe-command-adb-not-working-as-expected-in-a-macos-shell-script-but-works-fine%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Probability when a professor distributes a quiz and homework assignment to a class of n students.

Aardman Animations

Are they similar matrix