The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers > Answers to Frequently Asked Questions
Google UNIX.COM


Answers to Frequently Asked Questions Please look in here before posting your questions.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" iBot UNIX and Linux RSS News 0 01-04-2008 11:00 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 09:52 PM
how could i make a program mixed with many "|", "<" and ">" strugglingman High Level Programming 2 04-29-2006 05:11 AM
No utpmx entry: you must exec "login" from lowest level "shell" peterpan UNIX for Dummies Questions & Answers 0 01-18-2006 12:15 AM
how to request a "read" or "delivered" receipt for mails plelie2 Shell Programming and Scripting 1 08-06-2002 12:26 PM

 
 
Submit Tools LinkBack Thread Tools Display Modes
  #8 (permalink)  
Old 07-14-2002
Registered User
 

Join Date: Jun 2002
Location: Chennai, India
Posts: 110
Stumble this Post!
Thanks Perderabo. But what if i dont give this statement called magic numbers in my shell...

Anything wrong in it.. it almost looks like a coding standard for the script that we write...

Thanks,
Nisha
Forum Sponsor
  #9 (permalink)  
Old 07-15-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,443
Stumble this Post!
If you leave it out, then the shell will fail when it tries to exec() it. What happens next depends on which shell you are using as your login shell. Most shells will assume that the script is written in their own language. So if you are using bash as your login shell and try to run a korn shell script that didn't have the #! /usr/bin/ksh, then bash will try to run it as a bash script. bash and ksh are somewhat compatible and this might work. On the other hand, it might fail.

Suppose you use ksh as your login shell and you are running korn shell scripts without that first line. Things seem ok. Then you decide to try bash as your login shell. Suddenly things break.

And things will be especially grim for anyone who uses csh/tcsh as their login shell and runs scripts without that first line. These shells inspect the script to try and guess whether they or the old bourne shell should run it. The test they employ is so bad that it can be beaten by a random number generator. And no one still uses the old bourne shell anyway.

And yes, it is sort of a standard. Most kernels know about it. But I don't believe that is an official posix standard.
  #10 (permalink)  
Old 07-15-2002
Registered User
 

Join Date: Jun 2002
Location: Chennai, India
Posts: 110
Stumble this Post!
Thank you Perderabo..

That clears my doubts...

Thanks,
Nisha
  #11 (permalink)  
Old 02-08-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,443
Stumble this Post!
Also, from the USENET Unix FAQS, see Why do some scripts start with #! ... ?
And see this page and scroll down to the RATIONALE section near the end for info about a trailing hyphen on this line.
Google The UNIX and Linux Forums
 

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0