Bash scripting issue - input is always invalid
My input is always treated like invalid input with this script and I'm trying to work out why. I've cobbled this together from a ton of scripts I found online and I've had all kinds of mixed results, but this is the closest I've gotten to something that works...and yet...
Code:
#!/bin/bash |
Firstly, please use [code][/code] tags around code to keep formatting.
You have supplied code but not what you are entering to receive the invalid input? Having run the code on my machine, entering 1 or 2 seems to work just fine and anything else is received as invalid input correctly?? |
Grail, thank you.
I fixed the formatting, sorry. I meant to imply that any input I give it gets handled as invalid input. (or it had in previous versions, anyway) Wow, so...I just completely misunderstood the purpose of select. I thought the way it worked was to get the user to type "I AGREE' instead of a numerical response, I see numerical responses are working now (where they hadn't been across the many previous versions of this script) If I want to make my case statement hinge on the literal string input "I AGREE" can I still use select or do I need to use something else? Thanks for your help. |
Use read and case. read reads stdin to the specified variable.
Code:
read response |
Goumba, awesome. I've read (ha) with read that you need to worry about data sanitation, but I guess that's the price for grabbing a string literal from stdin.
|
I would just use a typical yes/no type answer like
Code:
ARE YOU SURE YOU WANT TO PROCEED? Code:
INSTALLATION SELECTED, DO YOU CONFIRM? |
All times are GMT -5. The time now is 05:41 PM. |