LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-21-2011, 09:47 PM   #1
scorchgeek
LQ Newbie
 
Registered: Jul 2011
Posts: 25

Rep: Reputation: Disabled
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.
 
Old 11-21-2011, 10:03 PM   #2
scorchgeek
LQ Newbie
 
Registered: Jul 2011
Posts: 25

Original Poster
Rep: Reputation: Disabled
Funnily enough, I found something applicable in the very next forum thread:
http://www.linuxquestions.org/questi...essage-914621/

After looking at zenity for a little while, this seems perfect. Bizarrely, however, it fails to work in my script.

Code:
export DISPLAY=:0.0
zenity --question
This does nothing. Running the same two lines in an at job works fine, though. The entry in my /etc/udev/rules.d/10-local.rules is:
Code:
ACTION=="add", KERNEL=="sd?1", ATTRS(idVendor)=="058f", ATTRS{idProduct}=="6387", RUN+="[path]/syncflash.sh"
The script runs fine. I just can't get that darned message box to appear.
 
Old 11-21-2011, 10:37 PM   #3
scorchgeek
LQ Newbie
 
Registered: Jul 2011
Posts: 25

Original Poster
Rep: Reputation: Disabled
Almost there...but TrueCrypt isn't cooperating

And now I have the following:

Code:
export DISPLAY=:0.0
sudo -u [username] zenity --info --text="hello"
password=$(sudo -u [username] zenity --password)
truecrypt --mount [ARCHIVE_LOCATION] /media/truecrypt1 -k [KEYFILE_LOCATION] -p="$password"
Here the info box appears as it should, the password box appears as it should, but for some reason TrueCrypt refuses to mount the volume. The script is being run as root (truecrypt needs to be run as root), and the password is correct. (Also tried putting the zenity password in the -p with $(); that didn't work either.)

Is there something obvious I'm missing?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripting for accepting input from different directories automatically kswapnadevi Programming 2 11-10-2010 12:11 PM
What is accepting input from IR?! Flyte Linux - Software 2 09-19-2010 07:00 PM
C interactive line input SciYro Programming 6 04-06-2007 01:57 PM
How to input several cmds to interactive apps through one shell cmd? kornerr Linux - General 4 01-01-2006 01:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration