Scripts without shebang


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripts without shebang
# 15  
Old 09-03-2012
@methyl

Thank you Methyl. Thanks everyone.

It is not recommended to invoke the Shell directly with a parameter of the script name (with or without the full path).

Didn't quite get you methyl. Can you elaborate ?



Yes. It is solaris 10 (x86-64 bit) as you've guessed.


Code:
$ uname -a
SunOS spikey213 5.10 Generic_147441-01 i86pc i386 i86pc

Output of
ls -lisad /bin/sh
ls -lisad /bin/bash

Code:
$ ls -lisad /bin/sh
        65    2 lrwxrwxrwx   1 root     root          13 Jun 23 00:07 /bin/sh -> ../../sbin/sh

$ ls -lisad /bin/bash
      4892 1296 -r-xr-xr-x   1 root     bin       654504 Feb  2  2011 /bin/bash

So, in solaris the default

man page of sh doesn't say anything explicitly about Bourne shell. But the word Bourne Shell is mentioned once (shown in red below)


Code:
$ man sh
Reformatting page.  Please Wait... done

User Commands                                               sh(1)

NAME
     sh, jsh - standard and job control shell and command  inter-
     preter

SYNOPSIS
     /usr/bin/sh [-acefhiknprstuvx] [argument]...

     /usr/xpg4/bin/sh [+ abCefhikmnoprstuvx]
         [+ o option]... [-c string] [arg]...

     /usr/bin/jsh [-acefhiknprstuvx] [argument]...

DESCRIPTION
     The /usr/bin/sh utility is a  command  programming  language
     that executes commands read from a terminal or a file.
----output snipped
.
.
.
The Bourne shell has a limitation on the effective UID for a
     process.  If this UID is less than 100 (and not equal to the
     real UID of the process), then the UID is reset to the  real
.
.
.

# 16  
Old 02-06-2013
I ran some simple tests on OSX and it appears that when the shebang is not specified, the first sh is used in the search path, rather than /bin/sh

Last edited by Scrutinizer; 02-06-2013 at 09:05 AM..
# 17  
Old 02-06-2013
That's either a shell implementation detail (the shell is not using a libc exec?p() interface) or Apple's libc does not adhere to its documentation.

From Apple's libc exec* manual (emphasis mine):
Quote:
If the header of a file is not recognized (the attempted execve() returned ENOEXEC), these functions
will execute the shell with the path of the file as its first argument. (If this attempt fails, no
further searching is done.)

... <snip> ...

FILES
/bin/sh The shell.
Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Necessity of shebang line

Hi , I know about the shebang line in shell scripting. Just want to know whether is there any difference in execution of the program by keeping and not keeping the shebang line. Because without shebang line also the script is working. correct me if am wrong. Any help on this will be helpful (5 Replies)
Discussion started by: rogerben
5 Replies

2. Shell Programming and Scripting

csh shebang query

What does the "-f" mean in following interpreter code #!/bin/csh -f Thank you (2 Replies)
Discussion started by: animesharma
2 Replies

3. Shell Programming and Scripting

Shebang

If i am not using #! in my script. By default where will be my script running? (6 Replies)
Discussion started by: Kochu77
6 Replies

4. Shell Programming and Scripting

Hyphen char after shebang notation

Hi, I have a trivial question to ask, I am seeing in some shell scripts the '-' (hyphen) character following the first line of shell script (i.e) the shebang notation as follows: #!/bin/sh - #! /bin/bash - what does the hyphen signify? What will happen if it is not given explicitly? (2 Replies)
Discussion started by: royalibrahim
2 Replies

5. Shell Programming and Scripting

The Shebang!

Hi, I always thought that #!/usr/bin/ksh means that the script would be executed in korn shell i.e. when we'll execute the script with this line as the very first line then the shell spawns a korn shell (in this case as we are using #!/usr/bin/ksh ) and the script gets executed. But I am... (7 Replies)
Discussion started by: dips_ag
7 Replies

6. Shell Programming and Scripting

Multiple shebang lines

*** EDIT: I found something close to my solution under an IIS 7 Module Handle.***** (Non-Homework question, simply an ease of use one) Odd question here and maybe its my newness to cgi/Perl, but is it possible to have 2 shebang lines? I write an test a ton of my homework code on my windows... (1 Reply)
Discussion started by: sennex
1 Replies

7. Shell Programming and Scripting

Relacing the shebang line of a file

Can any one tell me how to replace a shebang line of a file using sed? Eg: If a file contains the following shebang line #!C:/InstantRails/ruby/bin/ruby I would like to replace it with #!/usr/local/bin/ruby The shebang line of the file can be obtained from the command cat... (3 Replies)
Discussion started by: linuxnewbe
3 Replies

8. Shell Programming and Scripting

Doubt in shebang line!!

Do we need to include the exclamatory mark in the shebang line??:confused: What if we dont include it??:eek: Actually what shebang line implies when we run a script?? shebang line--> #!/bin/ksh :p (6 Replies)
Discussion started by: nohup
6 Replies

9. Shell Programming and Scripting

Shebang

Hi, I am currently writing BASH shell scripts. I am using BASH on a Powerbook G4 running Leopard. Could somebody please explain the difference between #!/bin/bash and #!/bin/sh? I have been using the latter (#!/bin/sh), and things have been working fine. But is that the correct one to use... (9 Replies)
Discussion started by: msb65
9 Replies
Login or Register to Ask a Question