0

I have this script which reads the user input for executing some command, This is working fine.

User=0
Path="/root/file/"
Path1="/root/domain/samples/file"
echo "Please select k1  l3  l8  o5  s2  s1  v1"
echo Location "Select the location eg: [k1 l3 l8 o5 s2 s1 v1]? "
read User
if [ $User = kw1 ]
    then
            echo unlink file
            echo ln -s $Path/$User $Path1/file
elif [ $User = lb3 ]
    then
            echo unlink file
            echo ln -s $Path/$User $Path1/file
elif [ $User = lo8 ]
    then
            echo unlink file
            echo ln -s $Path/$User $Path1/file  
            cp -p /domain/samples /domain/samples-org
            cp -p /root/l3 /domain/samples
else
echo "Specified location does not exist"
fi

Question

I was thinking of having a drop-down as shown below eg. what would be the possible approach?

#./script
    Eg: Please select from the below menu 
    1. Location k1  
    2. Location l3  
    3. Location l8  
    4. Location o5  
    5. Location s2  
    6. Location s1  
    7. Location v1
Enter number: 4 
Selected o5
Configuring.....
5
  • what is your question ?
    – Rahul
    Commented May 17, 2016 at 5:53
  • Are you asking if this is a good idea or for implementation help? If the latter, have you already tried anything?
    – forquare
    Commented May 17, 2016 at 5:54
  • 6
    This is what select is for. See tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_06.html for examples.
    – DopeGhoti
    Commented May 17, 2016 at 6:13
  • +1 for giving the link as well. Please post it as correct answer
    – ankidaemon
    Commented May 17, 2016 at 6:17
  • Forquare the above script is working, but I am trying to give it a drop down. So just want to know how it is done.
    – AReddy
    Commented May 17, 2016 at 6:23

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.