troubleshooting Question

need a quick help to fix the script logic

Avatar of The Rock
The RockFlag for India asked on
Linux DistributionsShell ScriptingScripting Languages
4 Comments1 Solution206 ViewsLast Modified:
Please help as i want to validate arguments passed while executing the script .

What i want that user can only give values as parameter those are valid as per script.

./ abc xyz                    where abc is a folder location which can be any location and xyz is either yes or no. if user enter any other word apart from yes or no then my message should be displayed and exit there only.

sample given below:

if [ $# -eq 2 ]; then
        if (($test1 == "audit") || ($test1 == "insert")); then
        echo "" or continue with the main script
        echo "please pass arguments like sample - Sample: ./ b1 audit. "
        exit 0;
    echo "invalid argument please pass only 2 argument "
    echo "Sample: ./ b1 audit"
    exit 0;
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros