Accepting Input With Non-Interactive Shell
Here's an interesting problem, and I have a feeling the solution will be changing the way I'm going about things.
I have a flash drive. When I plug in this drive, I want:
* My KeePass password database to be synchronized to it.
* The computer to mount my TrueCrypt volume using the password AND the keyfile which is stored on the flash drive. (The actual volume is stored on my hard drive.)
I have created a script that mounts the flash drive and synchronizes the password database, and set it to be triggered via udev. That part works great--plug in flash drive, database synchronized.
What doesn't work so well is the TrueCrypt part. TC has great command-line support, but the password prompt can't accept my password because when udev runs the script, it's in a non-interactive shell. (I could put the password on the command line in the script, but then that would circumvent the whole point of having a memorized password in the first place.)
So my first question is, is there any way I can possibly execute a command interactively, when the command is started automatically from a non-interactive shell? My second question is, is there another way I could accomplish all this that would let me do that (short of double-clicking the script when I plugged in the drive)? The only way I could think of is using cron or such to check if the drive is plugged in every so often, which would still suffer from the same problem.
EDIT: I'm using Ubuntu 11.04, if that matters at all.
|