zenity --password
input into a variable?I'm using zenity --password
to get input from the user and I'm trying to save it as a variable.
var=${zenity --password};
zenity var=--password
var=zenity --password
None of these work.
I got error codes from commands #2 and #3. The command #2 error code was:
You must specify a dialog type. See 'zenity --help' for details
The command #3 error code was:
-bash: --password: command not found
.
I'm not that familiar with bash, and I only know a few basic commands. The --password
command is from Zenity (sudo apt-get install zenity
). If somebody answers, thank you for helping!
Zenity Manual - https://help.gnome.org/users/zenity/stable/
Password Command - https://help.gnome.org/users/zenity/stable/password.html.en
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
zenity --password | sudo -S some_app_here
Example
#!/bin/bash
PASSWORD=$(zenity --password)
echo $PASSWORD | sudo -S "command"
echo $PASSWORD | sudo -S "command"
exit