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.
Asked
Active
Viewed 321 times
0

Gongq
- 3
2 Answers
0
chmod +x
makes the script executable.
Without it, the file is not executable, and can't be run.

Nmath
- 12,333
0
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.

vanadium
- 88,010
-
Hello, thank you for your help. After using a zip file, the script can be run without adding chmod after download. – Gongq Oct 24 '22 at 08:56
sh process.sh
orbash process.sh
as appropriate) provided it is readable - see for example Can scripts run even when they are not set as executable? – steeldriver Oct 23 '22 at 21:24