Ask Dave Taylor: Tech and Business


How can I prompt someone for a password within a shell script?

I'm the first to admit that there's nothing I can't do with a shell script, be it a graphical web-based interface to a data file or a powerful database query utility or whatever else. Indeed, I have a whole book on the subject: Wicked Cool Shell Scripts. But that's another story!

A reader query led me down an interesting path, demonstrating how to write shell scripts that prompt users for a password without actually echoing what they type, then comparing it to a password stored in a separate data file. If they match, all is well. If not, they need to be kicked off the system and banned:

    Passwords in Shell Scripts?

The bigger issue of how to prompt users for their official account password within a shell script can be done too, with a tiny bit of help, but is beyond the scope of that particular answer.