A colleague is going on holiday and leaves you a script, backup-notes.sh, which packs the team's notes into an archive. "Just run it," the message says. The script is in ~/script-lab, and there are three ways to run it.
Run your colleague's script
You are in ~/script-lab. Run backup-notes.sh with the three commands on the card, one after another.
First, predict
backup-notes.sh is yours and sits in the current directory. What will the shell answer to ./backup-notes.sh?
Now start the exercise, run the command and compare your prediction with the output.
Why was ./backup-notes.sh refused, even though the file is yours and you can read it?
-
You are already in ~/script-lab —
pwdshows it. And the file was found: otherwise the answer would beNo such file or directory. -
student runs programs in a home directory just fine. The problem is the file's own permissions:
ls -l backup-notes.shshows-rw-r--r--, with no x. -
sh found the error on line 5 once it started reading the file.
./was refused earlier, before any line was read.
A file can be run as a program only with the x permission, and backup-notes.sh does not have it.