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?
# 8  
Old 05-17-2012
I am using this at starting to get the OS and version of my software details, but getting below error. Is there anything wrong i have done?
Code:
#! /bin/ksh
MQV=`dspmqver|grep Version| awk '{print $2}'| sed 's/\.//g'`
if [ $? -gt 0 ]
then
MQV=`mqver|grep Version| awk '{print $2}'| sed 's/\.//g'`
fi

os=`uname`
sw=$MQV

if [ "$os" = Linux ] && [ "$sw" GE 6 ]; then

getting error
Code:
./m.sh[2]: dspmqver:

clue: I know 'dspmqver' command doesn't work on this server so it should execute 'mqver' only, but it is not getting done.. so i need your help here

---------- Post updated at 03:34 PM ---------- Previous update was at 09:27 AM ----------

can you please help me on this
# 9  
Old 05-17-2012
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
# 10  
Old 05-17-2012
Try looking for the dspmqver or mqver programs.

Code:
OLDIFS="$IFS"
IFS=":"

for DIR in $PATH
do
        for X in dspmqver mqver
        do
                [ -e "$DIR/$X" ] && CMD="$X"
        done
        [ ! -z "$CMD" ] && break
done

if [ -z "$CMD" ]
then
        echo "dspmqver and mqver not found"
        exit 1
fi

IFS="$OLDIFS"

MQVER=`$CMD | grep Version| awk '{print $2}'| sed 's/\.//g'`

# 11  
Old 05-18-2012
sorry i am little confused to where to use. shell i place it where i have given my code?

is below one correct? what is the condition should i use to change for every version like

if [ "$os" = Linux ] && [ "$sw" GE 6 ]; then

Code:
OLDIFS="$IFS"
IFS=":"

for DIR in $PATH
do
        for X in dspmqver mqver
        do
                [ -e "$DIR/$X" ] && CMD="$X"
        done
        [ ! -z "$CMD" ] && break
done

if [ -z "$CMD" ]
then
        echo "dspmqver and mqver not found"
        exit 1
fi

MQVER=`$CMD | grep Version| awk '{print $2}'| sed 's/\.//g'`

what it the condiong should i use here instead of
 if [ "$os" = Linux ] && [ "$sw" GE 6 ]; then

# 12  
Old 05-21-2012
I tried this above posted also not getting output...Smilie
# 13  
Old 05-22-2012
Check OS version first. I see that you have different ways of getting the software version depending on the OS.

Something on the following lines should work

Code:
case $os in

   "OS1") <get software version in way 1>;
         if [ "<software version>" = "A" ]
	 then
          <script1>
	 fi;;
   "OS2") <get software version in way 2>;
         if [ "<software version>" = "B" ]
	 then
          <script2>
	 fi;;
   "OS3") <get software version in way 3>;
         if [ "<software version>" = "C" ]
	 then
          <script3>
	 fi;;
   "OS4") <get software version in way 4>;
         if [ "<software version>" = "D" ]
	 then
          <script4>
	 fi;;
esac


Last edited by elixir_sinari; 05-22-2012 at 04:23 AM..
# 14  
Old 05-22-2012
Quote:
Originally Posted by darling
sorry i am little confused to where to use. shell i place it where i have given my code?
Wanting there to be $os and $sw variables won't make them exist for you. You're actually going to have to do the work, yourself, checking files and the like to tell what your system is.

I don't suppose you actually tried my code to see if it at least found the version of mq for you?
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