shell script asking for confirmation?
Hi, I am writing a script to create automatically email accounts. The input is from a file passed as parameter or from pipe.
The script should extract account name and person's details from each line and then ask for confirmation before creating the account. <Enter> to proceed, <Space> to skip, <Esc> to abort I found some instructions and examples for getting input with 'read' and '$<' but then how do I read only one character and dump(disregard) the rest? Also how do I check what character was entered. All of those are special characters. Should I use ASCII codes? Thanks! Koko |
<Enter> to proceed, <Space> to skip, <Esc> to abort
Sorry I aint answering your question (involves building a wrapper) but why make it hard if you can get away easily using regular keys for [a]dd and [s]kip and the CTRL+C exit combo (Bash: trap INT)? |
>Sorry I aint answering your question (involves building a wrapper) but why make it hard if you >can get away easily using regular keys for [a]dd and [s]kip and the CTRL+C exit combo (Bash: >trap INT)? [/B][/QUOTE]
Yep, I agree with you. Thanks for the help! |
Control characters make it more difficult, I would do something like this:
Code:
#!/bin/bash |
there is a shell function that does it for you.
It's called select you give it a list, it gives you a numbered menu. e.g: Code:
#!/bin/bash l |
The thing I don't like about select is it only gives you numerical choices, e.g.
1) Continue 2) Skip 3) Abort To me that makes it easier for the user to make a wrong choice. |
if the user is *that* stupid then best delete them
;-) |
All times are GMT -5. The time now is 05:10 AM. |