Reputation: 113
I would like to use expect with cryptsetup. It could be whatever program instead of cryptsetup. I feed cryptsetup with a device, a virtual device name and a password.
#!/bin/bash
read -p "Device: `echo $'\n> '`" DEV
read -p "Virtual Device: `echo $'\n> '`" VIRTUAL
read -p "Password: `echo $'\n> '`" PSWD
expect -c exec /sbin/cryptsetup luksOpen /dev/$DEV $VIRTUAL
expect "Enter passphrase for /dev/sdc1:"
send $PSWD
I also tried with 'spawn' but it does not work either. any idea is more than welcome! thanx folks.
Upvotes: 0
Views: 117
Reputation: 737
You can overcome the expect dependency by substituting the last three lines of codes with the following :
echo $PSWD | cryptsetup luksOpen /dev/$DEV $VIRTUAL
Upvotes: 1
Reputation: 881
As I understand you question and comments, you need something like this:
#!/bin/bash
read -p "Device: `echo $'\n> '`" DEV
read -p "Virtual Device: `echo $'\n> '`" VIRTUAL
/sbin/cryptsetup luksOpen /dev/$DEV $VIRTUAL
mount /dev/mapper/$VIRTUAL /mnt/$DEV
cryptsetup will ask you password, you will enter it. After this mount will run. That's all. And you don't need expect and any variable to store password.
Upvotes: 0