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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
running multiple scripts nvuradi Shell Programming and Scripting 3 08-13-2007 09:53 AM
How to make the same change in multiple shell scripts? rdakhan Shell Programming and Scripting 4 05-29-2007 07:21 PM
How to open multiple shells while the scripts keeps running. Closed_Socket UNIX for Dummies Questions & Answers 5 10-08-2006 10:06 AM
Multiple FTP scripts submitted to a subprocess tomstone_98 UNIX for Advanced & Expert Users 0 02-11-2005 11:11 AM
Porting of Windows written unix scripts to unix platform tamilselvi UNIX for Advanced & Expert Users 7 10-02-2002 10:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-13-2007
*ptr's Avatar
*ptr *ptr is offline
Registered User
  
 

Join Date: Mar 2007
Location: Romania - Bucharest
Posts: 11
Multiple platform scripts

Hello
I'm writing a script system in bash that I want to run on Un*x (SunOS), Linux, and cygwin also.
The scripts starts with the sha-bang #!/bin/bash, but I experienced that the bash interpreter path are different on these platforms.

My question is how can I manipulate the command interpreter line on my scripts
to run on each platform.
(I think to made a setup script to replace the first line in all of my scripts depending on the platform on which I'm running the scripts)
I also tried the:
#!/bin/bash
#!/usr/bin/local/bash
but if the command interpreter path are not correct in the first line, the OS does not looks for the command interpreter in the second line.

Many thanks beforehand
  #2 (permalink)  
Old 03-13-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,513
There may be other ways, but i find it easiest to just do this:
Code:
# bash yourscript.sh
This should take care of the shebang problem.
  #3 (permalink)  
Old 03-13-2007
*ptr's Avatar
*ptr *ptr is offline
Registered User
  
 

Join Date: Mar 2007
Location: Romania - Bucharest
Posts: 11
yes I know, but I want to launch my scripts in a normal form:
script_name.sh params.
Anyway, thanks.
  #4 (permalink)  
Old 03-13-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by *ptr
My question is how can I manipulate the command interpreter line on my scripts
to run on each platform.
#!/usr/bin/env bash
  #5 (permalink)  
Old 03-14-2007
*ptr's Avatar
*ptr *ptr is offline
Registered User
  
 

Join Date: Mar 2007
Location: Romania - Bucharest
Posts: 11
Quote:
Originally Posted by cfajohnson
#!/usr/bin/env bash
Yes, you're right thx. It works fine on Linux
But on SunOS the /usr/bin/env bash opens a new subshell, and my script doesn't start
running until I logout from the new shell. (actually no additional terminal is opened, just a shell started in the current terminal)
The newly started shell remains active until I press Ctrl+D one or more times to logout (on several scripts I observed that I need to press ^D three times to logout from the shell), after that the script starts running.

I'm wondering why exactly acts on SunOS in this way....

Anyway, thanks a lot for the suggestion Mr. Johnson
  #6 (permalink)  
Old 03-14-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
What version of Solaris are you using? cfajohnson's suggestion seems to work ok on Sol10.
  #7 (permalink)  
Old 03-14-2007
*ptr's Avatar
*ptr *ptr is offline
Registered User
  
 

Join Date: Mar 2007
Location: Romania - Bucharest
Posts: 11
SunOS 5.8 on Sparc SunBlade server
Closed Thread

Bookmarks

Tags
linux

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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