[svlug] Setting a files properties
Joseph Yetter
joey_e_y_jr at yahoo.com
Mon Jan 7 12:21:01 PST 2002
(just verified on RH7)
Strictly speaking, starting with "#!/command-interpreter" isn't
required. If the first character is NOT a "#", (and probably
the "magic" number isn't a known executable type), the shell
will fork a Bourne type shell to interpret/execute the script.
I say "Bourne type", because it's either SH, or if your existing
shell is BASH, then BASH is used. Both csh and tcsh call SH.
If the first character is "#", and the second is NOT "!", then
a CSH or TCSH will use another CSH or TCSH to interpret/execute
the script. A Bourne shell (SH) will use another Bourne shell,
so this can cause conflicts in all but the most simple cases.
It was a great help to script writers when the "#!" syntax
was introduced, and became common in the early 90's (as I
remember it). Very old Unix systems (System III, System VR2?)
might not support this, but Linux does.
However, being able to define your selected
interpreter is much better style, and more reliable.
cheers
-joe
-----Original Message-----
From: svlug-admin at lists.svlug.org [mailto:svlug-admin at lists.svlug.org]On
Behalf Of Jay Link
Sent: Monday, January 07, 2002 11:41 AM
To: svlug at svlug.org
Subject: Re: [svlug] Setting a files properties
> How do I make a script file execute when typing "./filename"?
>
> Can I use chmod to do this or is there a better way?
You must use chmod to make it executable, and you must also include
a line stating which interpreter will be used to run the script -- this
needs to appear before the first line of code.
Examples:
#!/bin/bash
or
#!/usr/bin/perl
More information about the Svlug
mailing list