The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 FAQ for UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 03:00 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
how could i make a program mixed with many "|", "<" and ">" strugglingman High Level Programming 2 04-29-2006 08:11 AM
No utpmx entry: you must exec "login" from lowest level "shell" peterpan UNIX for Dummies Questions & Answers 0 01-18-2006 04:15 AM
how to request a "read" or "delivered" receipt for mails plelie2 Shell Programming and Scripting 1 08-06-2002 03:26 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 07-15-2002
Nisha Nisha is offline
Registered User
  
 

Join Date: Jun 2002
Location: Chennai, India
Posts: 110
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
  #9 (permalink)  
Old 07-15-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
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-16-2002
Nisha Nisha is offline
Registered User
  
 

Join Date: Jun 2002
Location: Chennai, India
Posts: 110
Thank you Perderabo..

That clears my doubts...

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

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
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.
Sponsored Links
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0