Where/When exactly does the error message show up?
A couple of things to check:
(1) The chmod
command makes the script only executable, it does not run it. chmod +x abc.sh
will make your script executable.
Aside: I much prefer the "human readable" version of the chmod
command to the one using octal notation. So for instance:
chmod u+x file
means change file for user to executable (or just
+x
, the u
ser is implied by default).
You can specify g
roup, o
thers in place of u
, or combinations. In
place of x
you can use w
, r
etc, again in combinations if wanted
Use +
to add, -
to take away attributes.
See the chmod man page for more
information.
(2) Do you have the appropriate shell incantation at the top of your shell file? e.g.,
#!/bin/bash
(or whichever shell you want)
(3) How are you running it? This way should work:
./abc.sh
(4) Note: Your cd
command has a space (' '
) between the ~
and /generallstuff
.. hopefully that's just a typo in the posting; otherwise, the command will fail and you won't change directories!
chmod 755 abc.sh
does not execute the script but will set the appropriate permissions for the file. When does the error happen? Withchmod 755 abc.sh
or after you tried to run the script? – Ulrich Dangel Jun 15 '12 at 01:58cd ~/generalstuff
instead ofcd ~ /generalstuff
? – daisy Jun 15 '12 at 02:56/
in part in my answer where I mention how to run the script? – Levon Jun 15 '12 at 03:41