shell permissions

2 replies [Last post]
eleganszuma
User offline. Last seen 6 years 34 weeks ago. Offline
Joined: 07/18/2011

I have just created the example script dir.sh from chapter 6: scripting with the shell. The contents of the script are:

#! /bin/bash
ls -la
echo "Above are the directory listings for this folder:"
pwd
echo "Right now it is:"
date

I have not yet modified the permissions for this file, and yet it is already executable. ls-1 produces this:

-rwxr-xr-x@ 1 zuma staff 109 Jul 18 11:43 dir.sh

Should I be concerned about the security of my system? Is there a way to modify the default permissions for new files?

As you can tell, I am quite new at this... Thanks for any help!

Steve
User offline. Last seen 4 years 7 weeks ago. Offline
Joined: 08/15/2010
Shell permissions

We noticed that too. Your system is fine. It is because Textwrangler (or your editor) decided to make it executable when you saved the file as .sh.

Don't tell anyone, but the shebang line is actually optional (bash is the default) in shell scripts too. We wanted to get people used to the concept. It is good to keep in mind, though, because if you try to run a python script without the shebang, you will get weird error messages, corresponding to what would happen if you typed your script at the command prompt. For example: Usage: command not found, or import: command not found.

eleganszuma
User offline. Last seen 6 years 34 weeks ago. Offline
Joined: 07/18/2011
Probably should have said

Probably should have said that I am running Mac OS X.6.8