Re: Trouble with quotes in BASH scripts
Posted: 2012-04-18T22:25:11-07:00
A shell script only needs 'execute permission' if it starts with the UNIX #! syntax
You can add execute permission using
But even if it does not have the execute permission, OR a #! magic at the start, you can still execute it as a script. You just have to tell the system what parser to use..
For exampleor
Note the #! prefix at the start of the script is a special method to tell the 'kernel' what parser the the script uses. For shell scripts this is typically
But for non-shell parsers (such as perl) another method (more of a trick) is typically used
The "env" command will look for the "perl" parser anywhere on your command path and execute it. That means you do not have to hardcode its location in the #! line. "env" is common on all UNIX systems, and is often used for this purpose.
This will be imporant as the NEW IMv7 command ("convert" replacement) called "magick" can read options from a script, and such scripts are normally setup using magick of the form...
For more information see my notes about "SheBang" as it is called here
http://www.ict.griffith.edu.au/anthony/ ... hebang.txt
You can add execute permission using
Code: Select all
chmod a+x script_filename
For example
Code: Select all
sh script_filename
Code: Select all
bash script_filename
Code: Select all
#!/bin/sh
Code: Select all
#!/usr/bin/env perl
This will be imporant as the NEW IMv7 command ("convert" replacement) called "magick" can read options from a script, and such scripts are normally setup using magick of the form...
Code: Select all
#!/usr/bin/magick -script
# ...
For more information see my notes about "SheBang" as it is called here
http://www.ict.griffith.edu.au/anthony/ ... hebang.txt