0

I have the below script:

while true; do
  echo "# Available tests:"
  PS3="Please select which test must be performed [1-9]: "
  options=("CPU Stress Test (local)" "Memory Stress Test (local)" "Intensive Random Write I/O on disks (5 min) (local)" "Intensive Random Read I/O on disks (5 min) (local)" "Intensive Read I/O on disks (5 min) (local)" "Intensive Write on disks I/O (5 min) (local)" "Cache Read Capability (local)" "Measure Network Bandwidth (Between nodes)" "Quit")
  select opt in "${options[@]}"
  do
    case $opt in
    "CPU Stress Test (local)")
            sleep 2
            cpu
            cleanup
    ;;
    "Memory Stress Test (local)")
            sleep 2
            memory
            cleanup
    ;;
    "Intensive Random Write I/O on disks (5 min) (local)")
            prereq
            cslist
            randwrite
            sleep 2
    ;;
    "Intensive Random Read I/O on disks (5 min) (local)")
            sleep 2
    ;;
    "Intensive Read I/O on disks (5 min) (local)")
            sleep 2
    ;;
    "Intensive Write on disks I/O (5 min) (local)")
            sleep 2
    ;;
    "Cache Read Capability (local)")
            sleep 2
    ;;
    "Measure Network Bandwidth (Between nodes)")
            sleep 2
    ;;
    "Quit")
            echo "All right, bye bye! :)"
            echo "Exiting..."
            sleep 2
            exit 1
    ;;
    *) echo "Invalid option ($REPLY)";;
    esac
  done
done

If I choose option 1 CPU Stress Test (local) for example, it is being executed successfully but at the end appear only my PS3 question without the options from select opt in..., can anyone please help me?

Thank you

1 Answer 1

0

The select construct won't quit until a break command is executed.

So after each action is completed, use the break command:

    case $opt in
    "CPU Stress Test (local)")
            sleep 2
            cpu
            cleanup
            break
    ...
1
  • Thank you @schrodigerscatcuriosity !! Feb 23, 2021 at 19:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .