Score:0

Why doesn't chmod work in my bash script? Error is something about the directory...?

bd flag

Script is this:

#!bin/bash
echo "setpriv start"
chmod u=rwx ./ *
echo "setpriv end"

Output in bash window is this:

robertk@HP_2013:~$ bash -x setpriv
' echo 'setpriv start
setpriv start
' chmod u=rwx ./ '*
chmod: cannot access '*'$'\r': No such file or directory
' echo 'setpriv end
setpriv end
robertk@HP_2013:~$ ^C

????? Thanks -- something dumb / simple, I'm sure, but what???

hr flag
See ['\r' added end of the script command](https://askubuntu.com/questions/1148263/r-added-end-of-the-script-command). Also your shebang is missing the leading `/` i.e. `#!/bin/bash`
robertk avatar
bd flag
Not sure if I'm supposed to use a comment to thank you, or edit my original post, but THANK YOU, steeldriver, because your comments and link fixed the problem perfectly! I woudn't have found sed -i 's/\r//g' ... without your help. I altered my Notepad++ to select Unix "LF" as the sole line-end character, which might help.
robertk avatar
bd flag
Yes, that was it, exactly, THANKS! I'm a Linux newbie running Notepad++ on Win10 to edit my files, and a Ubuntu bash shell also on Win10. I'm not a fan of nano as an editor, but I have to say that my Notepad++ would work fine for a while, then slow down to 1/100 of its normal speed. I may have fixed this by upgrading manually from Notepad++ 7.95 to 8.1. I'm planning on programming in C++; bash shell programming should in theory be a side effect; all suggestions are welcome.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.