Solved

command %1 %2

Posted on 2002-07-24
3
194 Views
Last Modified: 2010-04-22
I want to make a script that can run diffent commands, like
command start

I started with the following code but now I am stuck.

Jeffeny

##### BEGIN ######

funct_param(){

# echo "$SWITCH"

if [ $SWITCH =  ]
then        
echo "Usage: command start | stop"
        exit 1
fi

if [ $SWITCH = start ]
then
        echo "start"
        exit 1
fi

if [ $SWITCH = stop ]
then
        echo "stop"
        exit 1
fi


}


##### MAIN ######

SWITCH=$1

       funct_param

##### END ######
0
Comment
Question by:harryv
  • 2
3 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
Comment Utility
Try this:

#!/bin/ksh
##### BEGIN ######

funct_param(){

if [ "$SWITCH" = "" ]
then
       echo "Usage: command start | stop"
       return 1
elif [ $SWITCH = start ]
then
       echo "Execute: start"
       $SWITCH
       return 0
elif [ $SWITCH = stop ]
then
       echo "Execute: stop"
       $SWITCH
       return 0
fi
return 0
}


##### MAIN ######

SWITCH=$1

funct_param
if [ $? -ne 0 ]
then
       echo "Command not executed"
       exit 1
fi
exit 0
##### END ######
0
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 50 total points
Comment Utility
Or....
#!/bin/ksh
##### BEGIN ######

funct_param(){

if [ "$SWITCH" = "" ]
then
       echo "Usage: command start | stop"
       return 1
elif [ $SWITCH = start ]
then
       echo "Execute: start"
       command $SWITCH
       return 0
elif [ $SWITCH = stop ]
then
       echo "Execute: stop"
       command $SWITCH
       return 0
fi
return 0
}


##### MAIN ######

SWITCH=$1

funct_param
if [ $? -ne 0 ]
then
       echo "Command $SWITCH not executed"
       exit 1
fi
exit 0
##### END ######
0
 

Author Comment

by:harryv
Comment Utility
Thankx, it does work like I want it.

Jeffeny
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now