Running a script at startup with rc.local (permission denied)












1














I prepared an image and included in /etc/rc.local a line to run a script:



/path/to/myscript.sh


I then created a script at that location



It contains a curl, to download and save a file as new file to the system. After this the file should be executed.



My problem is the following:



The content of the script I included directly to rc.local before and got an error permission denied.

It was the line downloading a scriptfile and save it locally.



Now I started to read further post and all said, it's better to exclude commands to a script file and launch the script file via rc.local only.



But the permissions-problem persists.



So I tried to modify my rc.local line:



/path/to/myscript.sh # not working
sudo /path/to/myscript.sh # not working


also in my script I added sudo to each command, it's not working.



Currently it seems curl with saving a file isn't allowed. (Internet connection exists).



Other posts say I should install a service.
Now I think it's going oversized and have no warranty. I need to run the script only once at reboot. In the script I tell the device to download bash-scripts and execute them.



So it seems I have a permission problem and I don't know how to fix it.



Maybe I used the wrong method to run a script after boot.



Why does this problem occur and how to fix ?










share|improve this question




















  • 2




    Are you sure that the script /path/to/myscript.sh is actually executable? What does ls -l /path/to/myscript.sh say?
    – AlexP
    Nov 27 '16 at 10:46
















1














I prepared an image and included in /etc/rc.local a line to run a script:



/path/to/myscript.sh


I then created a script at that location



It contains a curl, to download and save a file as new file to the system. After this the file should be executed.



My problem is the following:



The content of the script I included directly to rc.local before and got an error permission denied.

It was the line downloading a scriptfile and save it locally.



Now I started to read further post and all said, it's better to exclude commands to a script file and launch the script file via rc.local only.



But the permissions-problem persists.



So I tried to modify my rc.local line:



/path/to/myscript.sh # not working
sudo /path/to/myscript.sh # not working


also in my script I added sudo to each command, it's not working.



Currently it seems curl with saving a file isn't allowed. (Internet connection exists).



Other posts say I should install a service.
Now I think it's going oversized and have no warranty. I need to run the script only once at reboot. In the script I tell the device to download bash-scripts and execute them.



So it seems I have a permission problem and I don't know how to fix it.



Maybe I used the wrong method to run a script after boot.



Why does this problem occur and how to fix ?










share|improve this question




















  • 2




    Are you sure that the script /path/to/myscript.sh is actually executable? What does ls -l /path/to/myscript.sh say?
    – AlexP
    Nov 27 '16 at 10:46














1












1








1







I prepared an image and included in /etc/rc.local a line to run a script:



/path/to/myscript.sh


I then created a script at that location



It contains a curl, to download and save a file as new file to the system. After this the file should be executed.



My problem is the following:



The content of the script I included directly to rc.local before and got an error permission denied.

It was the line downloading a scriptfile and save it locally.



Now I started to read further post and all said, it's better to exclude commands to a script file and launch the script file via rc.local only.



But the permissions-problem persists.



So I tried to modify my rc.local line:



/path/to/myscript.sh # not working
sudo /path/to/myscript.sh # not working


also in my script I added sudo to each command, it's not working.



Currently it seems curl with saving a file isn't allowed. (Internet connection exists).



Other posts say I should install a service.
Now I think it's going oversized and have no warranty. I need to run the script only once at reboot. In the script I tell the device to download bash-scripts and execute them.



So it seems I have a permission problem and I don't know how to fix it.



Maybe I used the wrong method to run a script after boot.



Why does this problem occur and how to fix ?










share|improve this question















I prepared an image and included in /etc/rc.local a line to run a script:



/path/to/myscript.sh


I then created a script at that location



It contains a curl, to download and save a file as new file to the system. After this the file should be executed.



My problem is the following:



The content of the script I included directly to rc.local before and got an error permission denied.

It was the line downloading a scriptfile and save it locally.



Now I started to read further post and all said, it's better to exclude commands to a script file and launch the script file via rc.local only.



But the permissions-problem persists.



So I tried to modify my rc.local line:



/path/to/myscript.sh # not working
sudo /path/to/myscript.sh # not working


also in my script I added sudo to each command, it's not working.



Currently it seems curl with saving a file isn't allowed. (Internet connection exists).



Other posts say I should install a service.
Now I think it's going oversized and have no warranty. I need to run the script only once at reboot. In the script I tell the device to download bash-scripts and execute them.



So it seems I have a permission problem and I don't know how to fix it.



Maybe I used the wrong method to run a script after boot.



Why does this problem occur and how to fix ?







command-line bash permissions scripts startup






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '16 at 9:18









Zanna

50k13131238




50k13131238










asked Nov 27 '16 at 9:07









stefan83

8325




8325








  • 2




    Are you sure that the script /path/to/myscript.sh is actually executable? What does ls -l /path/to/myscript.sh say?
    – AlexP
    Nov 27 '16 at 10:46














  • 2




    Are you sure that the script /path/to/myscript.sh is actually executable? What does ls -l /path/to/myscript.sh say?
    – AlexP
    Nov 27 '16 at 10:46








2




2




Are you sure that the script /path/to/myscript.sh is actually executable? What does ls -l /path/to/myscript.sh say?
– AlexP
Nov 27 '16 at 10:46




Are you sure that the script /path/to/myscript.sh is actually executable? What does ls -l /path/to/myscript.sh say?
– AlexP
Nov 27 '16 at 10:46










1 Answer
1






active

oldest

votes


















1














# ls test.sh
-rw-r--r-- 1 root root 0 nov 27 13:40 test.sh

# ./test.sh
-su: ./test.sh: permission denied


To solve:



# chmod +x test.sh


Change test.sh for /path/to/myscript.sh






share|improve this answer





















  • Hmm you were a three year member with 1 point. Well now you have 11 points :)
    – WinEunuuchs2Unix
    Dec 9 at 17:41










  • Thanks! Will I get the 15 points in the next decade? ;)
    – Alonso Lara
    Dec 10 at 20:18











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f854152%2frunning-a-script-at-startup-with-rc-local-permission-denied%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














# ls test.sh
-rw-r--r-- 1 root root 0 nov 27 13:40 test.sh

# ./test.sh
-su: ./test.sh: permission denied


To solve:



# chmod +x test.sh


Change test.sh for /path/to/myscript.sh






share|improve this answer





















  • Hmm you were a three year member with 1 point. Well now you have 11 points :)
    – WinEunuuchs2Unix
    Dec 9 at 17:41










  • Thanks! Will I get the 15 points in the next decade? ;)
    – Alonso Lara
    Dec 10 at 20:18
















1














# ls test.sh
-rw-r--r-- 1 root root 0 nov 27 13:40 test.sh

# ./test.sh
-su: ./test.sh: permission denied


To solve:



# chmod +x test.sh


Change test.sh for /path/to/myscript.sh






share|improve this answer





















  • Hmm you were a three year member with 1 point. Well now you have 11 points :)
    – WinEunuuchs2Unix
    Dec 9 at 17:41










  • Thanks! Will I get the 15 points in the next decade? ;)
    – Alonso Lara
    Dec 10 at 20:18














1












1








1






# ls test.sh
-rw-r--r-- 1 root root 0 nov 27 13:40 test.sh

# ./test.sh
-su: ./test.sh: permission denied


To solve:



# chmod +x test.sh


Change test.sh for /path/to/myscript.sh






share|improve this answer












# ls test.sh
-rw-r--r-- 1 root root 0 nov 27 13:40 test.sh

# ./test.sh
-su: ./test.sh: permission denied


To solve:



# chmod +x test.sh


Change test.sh for /path/to/myscript.sh







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 27 '16 at 12:46









Alonso Lara

113




113












  • Hmm you were a three year member with 1 point. Well now you have 11 points :)
    – WinEunuuchs2Unix
    Dec 9 at 17:41










  • Thanks! Will I get the 15 points in the next decade? ;)
    – Alonso Lara
    Dec 10 at 20:18


















  • Hmm you were a three year member with 1 point. Well now you have 11 points :)
    – WinEunuuchs2Unix
    Dec 9 at 17:41










  • Thanks! Will I get the 15 points in the next decade? ;)
    – Alonso Lara
    Dec 10 at 20:18
















Hmm you were a three year member with 1 point. Well now you have 11 points :)
– WinEunuuchs2Unix
Dec 9 at 17:41




Hmm you were a three year member with 1 point. Well now you have 11 points :)
– WinEunuuchs2Unix
Dec 9 at 17:41












Thanks! Will I get the 15 points in the next decade? ;)
– Alonso Lara
Dec 10 at 20:18




Thanks! Will I get the 15 points in the next decade? ;)
– Alonso Lara
Dec 10 at 20:18


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • 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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2faskubuntu.com%2fquestions%2f854152%2frunning-a-script-at-startup-with-rc-local-permission-denied%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

Ellipse (mathématiques)

Quarter-circle Tiles

Mont Emei