?
Solved

command %1 %2

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

752 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