Quantcast
Channel: Active questions tagged password - Ask Ubuntu
Viewing all articles
Browse latest Browse all 332

BASH script - How to simulate user input for password

$
0
0

I'm trying to make a bash script used to unlock an external drive which is password-protected by WD proprietary software.Since I'm combining this with other bash scripts, I need it to take the password provided at the beginning with read -s -p "Enter WD password: " wdpassand use it when prompted by the WD script.

This is what I have so far:

#!/bin/bashsudo blkid #only need this to get the sudo password right awaywaitread -p "Enter drive ID (ie. sda): " driveidread -s -p "Enter WD password: " wdpasssudo apt install python3 python3-dev python3-pip git; sudo pip3 install git+https://github.com/evox95/wdpassport-utilssudo pip3 install --user git+https://github.com/crypto-universe/py_sgcd ~; wget https://raw.githubusercontent.com/evox95/wdpassport-utils/master/wdpassport-utils.pysudo ~/wdpassport-utils.py --unlock --device /dev/$driveidexpect "[wdpassport] password for /dev/${driveid}: "send "$wdpass"wait

I also tried the following combinations instead of expect and send (but nothing worked):

  • sudo ~/wdpassport-utils.py --unlock --device /dev/$driveid <(echo "$wdpass")
  • echo "$wdpass"
  • echo $wdpass
  • "$wdpass"
  • $wdpass

Viewing all articles
Browse latest Browse all 332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>