Solved

command %1 %2

Posted on 2002-07-24
3
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 7175273
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
ID: 7175285
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
ID: 7175613
Thankx, it does work like I want it.

Jeffeny
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
Suggested Courses

734 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