Reputation: 1557
Can someone help please?
I want to run a script that prompts the user to choose one of two options. upload or delete.
Whatever option is chosen, the user is then prompted for a name, and subsequently a version. Both of which are captured and inserted into an exec command. As an example, if I choose "foo" as the name, it then prompts me for a version. And if I choose "0.1.0", then my exec command looks something like this.
exec curl -XDELETE http://1.2.3.4/api/charts/foo/0.1.0
Upvotes: 1
Views: 89
Reputation: 46
This really isn't too hard of a script. I hope this will help.
#!/bin/bash
echo "UPLOAD or DELETE"
read option
if [ $option == "UPLOAD" ]
then
# Upload was selected. Now ask for name
echo "Please Enter A Name: "
read name
# Great! Now ask for a version number
echo "Please Enter A Version: "
read version
exec curl -XDELETE http://1.2.3.4/api/charts/$name/$version
elif [ $option == "DELETE" ]
then
# Delete was selected, do whatever you want here.
echo "Delete was selected!"
else
echo "That was not a valid option"
fi
The script asks the user for some input, ether (UPLOAD or DELETE). It then takes that value, if the value is "UPLOAD" then it will continue the script and ask for name and version number. If the user enters "DELETE" then it will echo out "Delete was selected!", That is where you can put whatever you want to finish the script. I hope this helps!
Upvotes: 1