Score:0

How to run Shell script without using chmod?

de flag

I wrote a Shell script and named it " process.sh ". I sent the script to my friend. I am curious if there is a way that he can run the script directly without using chmod +x process.sh. For example, he can directly run ./process.sh after downloading the script. Do I need to set anything for my script? Thank you for your help.

hr flag
They can run it directly with the shell for which it was written (e.g. `sh process.sh` or `bash process.sh` as appropriate) provided it is *readable* - see for example [Can scripts run even when they are not set as executable?](https://askubuntu.com/questions/25681/can-scripts-run-even-when-they-are-not-set-as-executable)
Score:0
ng flag

chmod +x makes the script executable.

Without it, the file is not executable, and can't be run.

Score:0
cn flag

It depends on how you "send" the script. If the file permissions are preserved, your friend will be able to run it directly. If not, then the executable bit needs to be set.

As an email attachment, permissions and ownerships are not preserved. Included in for example a .tar archive, permissions are preserved when extracting the archive. When using info-zip to create a zip file, permissions also can be preserved.

Gongq avatar
de flag
Hello, thank you for your help. After using a zip file, the script can be run without adding chmod after download.
I sit in a Tesla and translated this thread with Ai:

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.