Shebang of non-existent interpreter not giving error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shebang of non-existent interpreter not giving error
# 1  
Old 11-24-2013
Sha-bang of non-existent interpreter not giving error

I read that whenever you provide wrong path at sha-bang it will generate an error with message "command not found", but when I run script with wrong path, it runs perfectly without generating any error. any reason ?
Code:
#!/home/usrname/etc
echo "hello"
exit 0


Last edited by Qazi; 11-26-2013 at 08:22 AM.. Reason: Mistyped First ...
# 2  
Old 11-24-2013
From a bash terminal, OSX 10.7.5...
Code:
Last login: Sun Nov 24 12:48:58 on ttys000
AMIGA:barrywalker~> #!/Users/barrywalker
AMIGA:barrywalker~> echo "Hello World."
Hello World.
AMIGA:barrywalker~> # Now from a script...
AMIGA:barrywalker~> chmod 755 shebang.sh
AMIGA:barrywalker~> ./shebang.sh
-bash: ./shebang.sh: /Users/barrywalker: bad interpreter: Permission denied
AMIGA:barrywalker~> _

Script used for second part...
Code:
#!/Users/barrywalker
echo "Hello World."
exit

# 3  
Old 11-24-2013
It also depends where the "shebang" is in your script, and how you run the script.
# 4  
Old 11-25-2013
As wisecracker demonstrated and scott mentioned, how you run the script is important. The shebang isn't used when the script is read by a shell on stdin or passed to a shell as a command line argument. The shebang is only relevant when the script is passed as an argument to execve(2).

In wisecracker's second example, execve(2) finds the "interpreter" but it's not a regular file. This sets errno to EACCES, i.e. "Permission denied".

Regards,
Alister

Last edited by alister; 11-25-2013 at 07:37 AM.. Reason: Apologies for all the edits, but the original post had a critical error.
# 5  
Old 11-26-2013
Ok thanks scott and alister, I've change my shebang to sha-bang .. it was just mistyped ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a directory when its non-existent

Hi I need to create a directory when its non-existent Having an issue with the code here because it doesn't work can someone point what and how to change, please. ---------- Post updated at 11:08 AM ---------- Previous update was at 11:07 AM ---------- filelist=project_name/files/... (7 Replies)
Discussion started by: murari83.ds
7 Replies

2. Shell Programming and Scripting

Creating a directory if its non-existent within a script

Hi, is there a way to create a directory when its non-existent when trying to move files to this particular folder? Thanks much. (7 Replies)
Discussion started by: ida1215
7 Replies

3. AIX

multipath giving error

Hi, # lspath Missing hdisk0 fscsi0 Missing hdisk1 fscsi0 Missing hdisk2 fscsi0 Missing hdisk3 fscsi0 Missing hdisk4 fscsi0 Missing hdisk5 fscsi0 Missing hdisk6 fscsi0 Missing hdisk7 fscsi0 Missing hdisk8 fscsi0 Missing hdisk9 fscsi0 Missing hdisk10 fscsi0 Missing hdisk11... (2 Replies)
Discussion started by: JATA01
2 Replies

4. Shell Programming and Scripting

bc giving error: (standard_in) 2: parse error

Below part of script, is working fine sometimes and gives error sometime. I am doing float operations, checking if x > y. ##########CODE########## THRESHOLD="1.25" ratio=$( echo "scale=2; ${prev}/${current}" | bc ) if ; then split_date=`echo ${line} | cut -d, -f2` fi ... (9 Replies)
Discussion started by: manishma71
9 Replies

5. Shell Programming and Scripting

Executing expect script giving message as bad interpreter: Permission denied

Hi Gurus, I am new to scripting and needs your help in expect script used for telnet. I wrote a simple script as #!/usr/bin/expect-5.43 -f spawn telnet localhost 2233 expect "password:" send "secret\r" send "i data.cnbc.com\r" send "exit\r" expect eof When I am trying to execute... (2 Replies)
Discussion started by: niks_yv
2 Replies

6. Shell Programming and Scripting

Error in shell script when #!/bin/bash is used as shebang

#!/bin/ksh echo -en "\033|||'-')) echo -e "\033 The above script works fine when the interpreter is ksh, but outputs the following error when #!/bin/bash is used as shebang: test.sh: line 5: syntax error near unexpected token `(' test.sh: line 5: `case "$ACTIVATION_KEY" in +(|||'-'))' (2 Replies)
Discussion started by: proactiveaditya
2 Replies

7. Ubuntu

How to resolve bad interpreter error

Hi, Iam trying to run a gmake command and have the latest version of Gnu in my redhat linux system. I need to execute the following steps; ---> chmod +x utils/* ---> ./utils/AllCodeManagerFix ---> gmake LINUX Iam able to do the chmod command but when I run the second command I get... (2 Replies)
Discussion started by: viji19812001
2 Replies

8. UNIX for Advanced & Expert Users

script giving error

Hi All, i have an small issue... echo " " eval x=$@ export x=`echo $x` echo $x ssh user@ipadrss; cd /mbbv/home/; cd /mbbv/home/orange/orange/ echo pwd bash samplescript.sh $x above is my script which will triger from server A and will connect to server B for some... (2 Replies)
Discussion started by: Shahul
2 Replies

9. Shell Programming and Scripting

Checking for future / non existent dates

'm attempting to script an application for the bash shell. The application needs to check for birthday, but must check the birthday to see if the date is a) in the future b) exists at all (ie Feb 29th during non-leap years). The input is being entered in a YYYYMMDD format, so I was hoping someone... (2 Replies)
Discussion started by: DKNUCKLES
2 Replies

10. Shell Programming and Scripting

add or modify if existent

I want to set these params in /etc/system set shmsys:shminfo_shmmax=2000000000 set shmseg:shminfo_shmseg=200 if this param exists, then I want to modify them if not, I want to add them. I can add them using >>/etc/system but how to do the modify thing? at least I can comment the... (4 Replies)
Discussion started by: melanie_pfefer
4 Replies
Login or Register to Ask a Question