tags:

views:

101

answers:

3

I recently decided to try to learn some bash scripting and as a fun exercise I decided to make a script to open up a daily file for me to write notes in whenever the script is run.

It worked fine until I logged out and back in to the system later, when I received an error

/usr/local/bin/notes: line 45: /home/MY_USERNAME/notes/2010-10-01:Permission denied

Code

I might be mistaken, but this certainly doesn't seem like something that shouldn't require extra permissions, does it?

Editor is set to nano

File's permissions are -rw-rw-r--

Script's permissions are -rwxr-xr-x

A: 

check the permission on the file with

ls -l /path/to/your/file

you should see something like

-rw-r--r--

r mean readable, w writeable, and x executable.

the first set is for your user, the second set of three is for your group, and the third set is for anyone.

so in my example, the file i have shown is read/write for me, and read only for my group and for any other user.

Use the chmod command to change permissions.

chmod 744 file

will make the file read/write/exec for you, and just read for user/world.

hvgotcodes
+4  A: 

My guess is that in

 $EDITOR $DAILY_FILENAME 

$EDITOR is null, so it's trying to execute $DAILY_FILENAME which not executable. Probably while you were testing you set EDITOR manually, but didn't add it to your .bashrc (or whatever) file.

Use the -x option to prove it.

djna
Yeah, I guess I didn't permanently set the editor variable, I only had it set for that session. Thanks
Michi
A: 

If I had to guess, I would suggest that the $EDITOR environment variable is undefined for some reason. It looks like your script is attempting to execute the notes file - as this isn't executable you get the unhelpful error message.

Andrew Walker