Advanced Bash-Scripting HOWTO: A guide to shell scripting, using Bash | ||
---|---|---|
Prev | Chapter 2. Starting Off With a Sha-Bang | Next |
Having written the script, you can invoke it by sh scriptname, or alternately bash scriptname. (Not recommended is using sh <scriptname, since this effectively disables reading from input within the script.) Much more convenient is to make the script itself directly executable by
chmod 755 scriptname (gives everyone execute permission)
chmod +x scriptname (gives everyone execute permission)
chmod u+x scriptname (gives only the script owner execute permission)
In this case, you could try calling the script by ./scriptname.
As a final step, after testing and debugging, you would likely want to move it to /usr/local/bin (as root, of course), to make the script available to yourself and all other users as a system-wide executable. The script could then be invoked by simply typing scriptname [return] from the command line.