How to call different programs based on requirement?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to call different programs based on requirement?
# 1  
Old 05-14-2012
How to call different programs based on requirement?

Hi Team,

I have four shell scripts and i need to put it into one script and call based on requirement.

For example:

If server is Linux and version of my software version is 5 then it should call 1st scipt


If server is Solaris and version of my software version is 6 then it should call 2nd scipt


If server is Linux and version of my software version is 6 then it should call 3rd scipt


So please help me how to merge all scripting files in one file. So i can place it on all servers, when i run it it will check Server os(by using uname -a) and my software version, then it calls the shell script which is written for that combination.Please let me know how to do it
# 2  
Old 05-14-2012
Bug

At the start of the script you can add one if condition for checking version of the system and accordingly you can execute the script.
# 3  
Old 05-14-2012
How do you check your software version?

Code:
os=$(uname)
sw=$(...)

if [ "$os" = Linux ] && [ "$sw" = v5 ]; then
 ## call first script or so
elif [ "$os" = SunOS ] && [ "$sw" = v4 ]; then
 ## call second script or so
elif [ "$os" = HP-UX ] && [ "$sw" = v3 ]; then
.
.
elif [ "$os" = fedora ] && [ "$sw" = v4 ]; then
 ## do accordingly
else
 ## do else part
fi

# 4  
Old 05-14-2012
Thanks but my worry is how to place all in one script. How to devide are how allign the number when script calls
# 5  
Old 05-14-2012
I did not actually get this !
Align which numbers? do you want to call script in a numbered order?

Please elaborate more with providing the samples of the following..

- Name of the scripts
- Conditions
- Command to call the script based on condition

Better to provide the complete example.
# 6  
Old 05-14-2012
Ok let me explain
i have a script which will give the output only for linux server and software of 5. This is my first script
i have a script which will give the output only for linux server and software of 6. This is my second script
i have a script which will give the output only for solaris server and software of 5. This is my third script
i have a script which will give the output only for solaris server and software of 6. This is my fourth script
so all are four different scripts. Now what i want is all should run with just one script. lets call this script as Onescript.sh
when i run this ./Onescript.sh it should check my conditions (server os and my software vesion) and it should call the script which i already placed. For example

if output is Linux and 6 then it should run my second script. I hope it clarifies

---------- Post updated at 09:38 AM ---------- Previous update was at 06:49 AM ----------

let me explain little detailed
Code:
i have a script which will give the output only for linux server and software of 5. This script is one.sh
i have a script which will give the output only for linux server and software of 6. This script is two.sh
i have a script which will give the output only for solaris server and software of 5. This script is three.sh
i have a script which will give the output only for solaris server and software of 6. This script is four.sh
so all are four different scripts. Now what i want is all should run with just one script, it means i need to put all four scripts in one scriot. lets call this script as Onescript.sh

when i run this ./Onescript.sh it should check my conditions (server os and my software vesion) and it should call the script which i already placed. For example
if output is Linux and 6 then it should run two.sh and gives the output. I hope it clarifies

Last edited by darling; 05-14-2012 at 09:27 AM..
# 7  
Old 05-14-2012
I provided solution for the same you explained above.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call script parameter based on dates

Hi Guys, I am having a script which needs to be iterated based on date passed and itrate based on no of months given. #!/bin/bash var_d=$1 months=$2 sh invoke_script var_d i need to iterate the inside script something like below sh invoke_script 170101 sh invoke_script... (4 Replies)
Discussion started by: Master_Mind
4 Replies

2. Shell Programming and Scripting

awk script to call another script based on second column entry

Hi I have a text file (Input.txt) with two column entries separated by tab as given below: aaa str1 bbb str2 cccccc str3 dddd str4 eee str3 ssss str2 sdf str3 hhh str1 fff str2 ccc str3 ..... ..... ..... (1 Reply)
Discussion started by: my_Perl
1 Replies

3. UNIX for Dummies Questions & Answers

Difference between inbuilt suid programs and user defined root suid programs under bash shell?

Hey guys, Suppose i run passwd via bash shell. It is a suid program, which temporarily runs as root(owner) and modifies the user entries. However, when i write a C file and give 4755 permission and root ownership to the 'a.out' file , it doesn't run as root in bash shell. I verified this by... (2 Replies)
Discussion started by: syncmaster
2 Replies

4. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

5. UNIX for Dummies Questions & Answers

Are programs like sys_open( ) ,sys_read( ) et al examples of system level programs ?

Are the programs written on schedulers ,thread library , process management, memory management, et al called systems programs ? How are they different from the programs that implement functions like open() , printf() , scanf() , read() .. they have a prefix sys_open, sys_close, sys_read etc , right... (1 Reply)
Discussion started by: vishwamitra
1 Replies

6. UNIX for Dummies Questions & Answers

how to call two programs simultaneously

Hi, i want to call two programs simultaneously from a currently running program so as to distribute the job and fasten the speed. As of now I call the programs one after the other within the main program. e.g. `perl A.pl`; `perl B.pl`; how can I run the two paralelly? urgent ... please... (1 Reply)
Discussion started by: vipinccmb
1 Replies

7. Shell Programming and Scripting

Perl call C programs

Hi, I am a beginner in Perl programming. Now i need to call a C program from a perl program ...Can any one please help me and give any details how i can do this. Thanks and Regards (3 Replies)
Discussion started by: gjithin
3 Replies

8. Shell Programming and Scripting

Picking the file based on Date..Requirement

Dear frnds My requirement is as follows -rw-r----- 1 f02 dd 109428250 May 18 14:02 Extracts_20070518104730.zip -rw-r----- 1 f02 dd 109493187 May 21 13:30 Extracts_20070521091700.zip -rw-r----- 1 f02 dd 109993058 May 23 14:14 Extracts_20070523085955.zip -rw-r----- 1... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

9. Programming

call functions from diferents programs

hi i have ten program in C, and there are functions what are in all the programs. so, i want to make a directory to store all the functions what are in all the programs, and call them from the C programs. (sending variables and values) is that possible?¿? how ca i do that?¿? any idea,... (1 Reply)
Discussion started by: DebianJ
1 Replies
Login or Register to Ask a Question