LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-04-2007, 10:53 PM   #16
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30

Thanks chrism01,


Quote:
Originally Posted by chrism01 View Post
The point of specifying the shell your code requires (on production systems) is so that you don't end up with a script that partially runs, then screws up/crashes because it's running under the wrong intepreter.
It's much safer for it not to run at all if it can't find the correct interpreter.
It can cost a company a lot of money if it goes wrong...
It also tells the sysadmin/maintenance prog which shell it will work with, rather than them having to guess.
You might not be avail to be asked when it goes pear-shaped ...
Your practical advice is very helpful.


regards,
George
 
Old 09-04-2007, 11:44 PM   #17
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks cfaj,


Quote:
Originally Posted by cfaj View Post

If you are calling a script as the argument to a shell, the shebang makes no difference; it is just another comment. The shebang is only used when the script is executed as a command.
This is an important point. Previously, I think if we add shebang into the 1st line of shell script and at the same time using sh to execute, shell process will be started twice (1st time sh, 2nd time by the shebang line).


regards,
George
 
Old 09-04-2007, 11:46 PM   #18
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks for your advice, makyo!


Quote:
Originally Posted by makyo View Post
Hi.

The portability of scripts is decreased if you specify an absolute path.

I once used Solaris often and ran into such problems going back and forth to and from Linux.

I use a perl utility, fixin (fix interpreter), that adjusts the shebang line of scripts for the correct path. It works not only for perl shebangs, but for anything you have in a shebang -- awk, sh, etc.

The fixin program was published in one of the first Programming perl books. An on-line copy of the code is http://search.cpan.org/src/JOHNL/DBD...mples/fixin.pl

Best wishes ... cheers, makyo

PS The origin of the word shebang can be found at http://en.wikipedia.org/wiki/Shebang_%28Unix%29

regards,
George
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 04:35 PM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 12:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration