The -A
sudo option allows you to specify a helper program (in the SUDO_ASKPASS variable) that will ask for the password.
Create a script to ask the password (myaskpass.sh):
#!/bin/bash
zenity --password --title=Authentication
Then insert this line at the beginning of your script:
export SUDO_ASKPASS="/path/to/myaskpass.sh"
and replace all occurences of sudo <command>
with:
sudo -A <command>
You can use whatever password asking program you want instead of zenity
. I had to encapsulate it within a script because SUDO_ASKPASS must point to a file, so it won't work with the --password
option required by zenity
.
The above works like a charm if it runs from command line or if you choose Run in terminal after double click the script file in the file manager, but if you choose Run or try to launch it from a .desktop file every sudo
will ask for the for password again.
If you don't want a terminal window at all, you can store the password in a variable and pipe it to sudo -S
. Maybe there's some security concerns, but I think it's pretty safe (read the comments on this answer).
Insert this line at the beginning of your script:
PASSWD="$(zenity --password --title=Authentication)\n"
and replace all occurences of sudo <command>
with:
echo -e $PASSWD | sudo -S <command>
You can't do apt-get update
from the command line of the update manager.
To run the command, use
update-manager
man update-manaer
gives:
--data-dir=DATA_DIR
Directory that contains the data files
-c, --check-dist-upgrades
Check if a new distribution release is available
-d, --devel-release
Check if upgrading to the latest devel release is possible
-p, --proposed
Upgrade using the latest proposed version of the release
upgrader
--no-focus-on-map
Do not focus on map when starting
--dist-upgrade
Try to run a dist-upgrade
so you can move over by running
update-manager --dist-upgrade
Best Answer
Yad may be useful in this regard, it is a fork of zenity with more features, one of them the ability to create forms.
Here is a very simple example of a form:
The above script will display a form like this:
After you enter your data and click ok or hit enter on the keyboard, the form data will be written to a text file called test.txt, I am using awk to separate the form data which is a string with a pipe as field separator, I believe there is a direct way to get the data without awk but I am no yad expert, please check the project home and ask questions, you may find a more elegant way.
How to get and install yad here:
http://www.webupd8.org/2010/12/yad-zenity-on-steroids-display.html
yad project home:
http://code.google.com/p/yad/
more examples here:
http://technostripe.com/yad-a-fork-of-zenity-with-more-features/
http://code.google.com/p/yad/wiki/Examples
I am late here but this may still be helpful.