|
Home > Archive > Unix Shell > October 2006 > Is this mandatory #!/bin/ksh
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Is this mandatory #!/bin/ksh
|
|
| nicetom786@yahoo.com 2006-10-24, 7:17 pm |
| I am new to Unix and let me know this question.
Is this mandatory
#!/bin/ksh in the first line of script?
What exactly this means.
| |
| Damian 'legion' Szuberski 2006-10-24, 7:17 pm |
| On 2006-10-24, nicetom786@yahoo.com wrote:
> Is this mandatory
> #!/bin/ksh in the first line of script?
> What exactly this means.
Keyword: sha-bang
To process script OS will use /bin/ksh. You may use /bin/sh,
/usr/bin/perl /usr/bin/python as well.
--
Damian Szuberski
| |
| Michael Tosch 2006-10-24, 7:17 pm |
| Damian 'legion' Szuberski wrote:
> On 2006-10-24, nicetom786@yahoo.com wrote:
> Keyword: sha-bang
> To process script OS will use /bin/ksh. You may use /bin/sh,
> /usr/bin/perl /usr/bin/python as well.
>
sha-bang? shebang!
Without a shebang the OS might reject to run the script
or revert to a "default" script interpreter.
This "default" is different on different OS,
and on some OS can depend on your login shell.
(OS=OperatingSystem)
So it is safer to have the
#!/bin/ksh
--
Michael Tosch @ hp : com
| |
| Damian 'legion' Szuberski 2006-10-24, 7:17 pm |
| On 2006-10-24, Michael Tosch wrote:
> sha-bang? shebang!
sha-bang is proper as well.
--
Damian Szuberski
| |
| Chris Mattern 2006-10-24, 7:17 pm |
| In article <1161720475.266600.293070@e3g2000cwe.googlegroups.com>,
nicetom786@yahoo.com wrote:
>I am new to Unix and let me know this question.
>
>Is this mandatory
>#!/bin/ksh in the first line of script?
>What exactly this means.
>
It tells the kernel: "When loading this file for execution,
load the file named here instead and submit the pathname
of this file as its parameter." It's a quick and easy
way to run scripts that use an interpreter. You need
it if you want to run your script just by typing its
name. You can always just invoke the interpreter yourself
on the command line: "/bin/ksh this.script".
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
| |
| Chris F.A. Johnson 2006-10-24, 7:17 pm |
| On 2006-10-24, nicetom786@yahoo.com wrote:
> I am new to Unix and let me know this question.
>
> Is this mandatory
> #!/bin/ksh in the first line of script?
No, it's not mandatory.
> What exactly this means.
It tells the system (e.g., the kernel, or the current shell) which
interpreter to use to run the script.
If it's not there, the default shell will be used. This might be
/bin/sh, or it migh be the current shell. Bash, for instance, will
run the script itself if there is not shebang line.
If your system has a POSIX shell in /bin/sh, and you write your
scripts to conform to that standard (which is more than adequate
for most scripting needs), the shebang is not necessary.
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
| |
| Daniel Rock 2006-10-24, 7:17 pm |
| Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
> If it's not there, the default shell will be used.
Not always. Only in a shell environment or via execlp() or execvp().
But not via execve() or others of the exec*() functions.
--
Daniel
|
|
|
|
|