Multiple platform scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple platform scripts
# 1  
Old 03-13-2007
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  
Old 03-13-2007
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  
Old 03-13-2007
yes I know, but I want to launch my scripts in a normal form:
script_name.sh params.
Anyway, thanks.
# 4  
Old 03-13-2007
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  
Old 03-14-2007
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  
Old 03-14-2007
What version of Solaris are you using? cfajohnson's suggestion seems to work ok on Sol10.
# 7  
Old 03-14-2007
SunOS 5.8 on Sparc SunBlade server
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Multiple Users - Multiple Scripts

Hello All, I have to restart 100's of scripts for at least 20+ users once the server restarts for any reason. I wanted to come up with a single script to trigger of all scripts/programs under all users with just one script (without root privilege). Is it possible to do so? :confused: If not,... (6 Replies)
Discussion started by: PikK45
6 Replies

2. UNIX for Beginners Questions & Answers

To run multiple scripts

Hi , Can someone help! I need a shell script to run multiple scripts by using single shell script, incase any one of the scripts fails, it should get exit and after trouble shooting if we re-execute it, it should start from the failed script (4 Replies)
Discussion started by: anniesurolyn
4 Replies

3. Shell Programming and Scripting

Running Multiple scripts at a time

Hello! I have a scriptA.ksh and in this script I need to call script1.ksh, script2.ksh, script3.ksh, script4.ksh and script5.ksh. But want to run in two batches like 1st script1.ksh, script2.ksh, script3.ksh, once all 3 are completed then script4.ksh script5.ksh I have given the syntax... (1 Reply)
Discussion started by: karumudi7
1 Replies

4. Shell Programming and Scripting

Executing multiple scripts using if condition

I have an if condition. If that condition is true then one script will be run and after that I need to check another condition based on the output value of first script. i tried like below : cd lock if ; then rm exitup if ; then kb_shutdown kb_startup if ; then rm exitup if ;... (3 Replies)
Discussion started by: charanarjun
3 Replies

5. Shell Programming and Scripting

Sessions across multiple scripts.

I wish to be able to pass PHP values between multiple scripts. In each script, I have the following before any HTML code: <?php session_start(); session_name("STORE"); session_set_cookie_params( 'lifetime', '/var/www' ); session_id('Gingy'); ... (1 Reply)
Discussion started by: Meow613
1 Replies

6. Shell Programming and Scripting

Calling multiple scripts from another scripts

Dear all, I am working on script which call other shell scripts in a loop but problem is from second script am not able to come out. Here is the snippet:- #!/bin/bash HSFILE=/root/Test/Components.txt LOGFile=/opt/domain/AdminDomain/application/logs... (3 Replies)
Discussion started by: sharsour
3 Replies

7. Shell Programming and Scripting

Searching of IP_add in multiple scripts

Hi forum memebers, I want know what is the grep command a IP_add or host in the multiple scripts in one directory. Thanks in advance. Siva Ranganath.:) (3 Replies)
Discussion started by: sivaranga001
3 Replies

8. UNIX for Dummies Questions & Answers

usage of same variable in multiple scripts

Hi, I have a .test file which has: #!/bin/ksh export TEST_FLAG=1 In the test1.ksh i have: #!/bin/ksh . .test echo $TEST_FLAG When i execute the test1.ksh its showing the value as 1. But if i refer the same variable in another script, the value is not 1. Basically, I need to have... (1 Reply)
Discussion started by: risshanth
1 Replies

9. Shell Programming and Scripting

running multiple scripts

Hi all I have a requirement where I have a flow like Script1 script2 Script3 Script 4 Script 5 Script 6 script7 where script2 to script6 will... (3 Replies)
Discussion started by: nvuradi
3 Replies

10. UNIX for Advanced & Expert Users

Porting of Windows written unix scripts to unix platform

Can anybody help me in finding out a solution for the problem below? When we write .unix or .sh files in windows OS and port them to Unix platforms there is a character ^M inserted at the end of each line of the script file. During ftp porting I set the transfer mode as ASCII for the script... (7 Replies)
Discussion started by: tamilselvi
7 Replies
Login or Register to Ask a Question