Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

command %1 %2

Posted on 2002-07-24
3
Medium Priority
?
207 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 200 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

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 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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

598 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