Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- #############################################################################
- # enforce root permissions
- ROOT_UID=0
- E_NOTROOT=87
- if [ "$UID" -ne "$ROOT_UID" ]
- then
- echo "You must be root to run this script."
- exit $E_NOTROOT
- fi
- #############################################################################
- # set $UTCTIME variable
- UTCTIME=$(/bin/date --utc +"%Y%m%d_%H%M%Z")
- #############################################################################
- # generate menu
- prompt="Select an option:"
- options=("Edit TARGET variable" "Edit TOOL variable" "Display current values")
- PS3="$prompt "
- select opt in "${options[@]}" "Quit"; do
- case "$REPLY" in
- #############################################################################
- # option: edit TARGET variable
- 1 )
- echo ""
- echo "Editing" '$TARGET' "variable..."
- sleep 2
- echo "Variable" '$TARGET' "currently equals: $TARGET"
- echo "Please enter your new target (lower-case, no spaces):"
- read TARGET
- echo "Variable" '$TARGET' "now equals: $TARGET"
- echo ""
- FILENAME=$TARGET\_$UTCTIME\_$TOOL
- sleep 1;;
- #############################################################################
- # option: edit TOOL variable
- 2 )
- echo ""
- echo "Editing" '$TOOL' "variable..."
- sleep 2
- echo "Variable" '$TOOL' "currently equals: $TOOL"
- echo "Please enter your new tool (lower-case, no spaces):"
- read TOOL
- echo "Variable" '$TOOL' "now equals: $TOOL"
- echo ""
- FILENAME=$TARGET\_$UTCTIME\_$TOOL
- sleep 1;;
- #############################################################################
- # option: display current values
- 3 )
- echo ""
- echo "Variable" '$TARGET' "currently equals: $TARGET"
- echo "The current UTCTIME is: "$UTCTIME
- echo "Variable" '$TOOL' "currently equals: $TOOL"
- echo "Variable" '$FILENAME' "currently equals: $FILENAME"
- sleep 1;;
- ##############################################################################
- # option: quit
- $(( ${#options[@]}+1 )) )
- echo ""
- echo "Your format variable," '$FILENAME' "appears as the following:"
- sleep 1
- echo "$FILENAME"
- echo "";
- break;;
- #############################################################################
- # option: invalid
- *)
- echo ""
- echo "Invalid option.";
- echo ""
- continue;;
- #############################################################################
- esac
- done
- # if this script is called via 'source <scriptname.sh>', then
- # calling 'exit' at the end of the script will close the shell.
- # exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement