Skip to content
Advertisement

Running a script in terminal using Linux

Im trying to run this script in the terminal but its not working and says permission denied. scriptEmail is filename.

JavaScript

scriptEmail is written as follows:

JavaScript

My read write permission

JavaScript

Advertisement

Answer

As for permissions:

  • Check that your shebang is at the very top of your file, and that it starts exactly with #!; # ! will not work.
  • Check that your files are given execute permissions; chmod 750 scriptEmail will do.
  • Check that your file uses UNIX newlines — with DOS newlines, your shebang may have a hidden character making it point to an interpreter which doesn’t actually exist.
  • Check that the directory your file is stored in is in a directory where executable scripts are allowed (not mounted with the noexec flag, or in a SELinux context disallowing execution).

If your mount point is noexec or your ability to create executable scripts is blocked by SELinux or similar, then use find . -type d -exec bash ./scriptEmail {} ; to explicitly specify an interpreter rather than attempting to execute your script.


Second: Since you’re executing your script with find already — and using that to recurse through directories — you don’t need a second find inside (which would have you potentially operating on processed/dirA/dirB/file as well as processed/dirB/file and processed/file — with errors for all of these where the directory doesn’t exist).

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement