Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using kdialog for a small Utility in making, Now i run into this promblem. There is one or more commbined functions that take sudo 3 or 4 times in a row. So its really annoying to have to enter it that many times.

I would like to use kdialog --password to store my sudo password every time i open the app it would store in a variable. This way its not sitting in a file or something. Any way, i can see that it stores just find i can echo $passwrd. But i have no clue how to have it input into the terminal when it askes for it. Is this possible? If so how, even if a diffrent approch. If not what is the actual use of kdialog --password ? If you cant do this is see very little use for it really.

Thank you.

share|improve this question

You might have got the answer by now, but i am still posting it here. You can use expect command to send the password (stored in the 'passwd' variable) to the terminal when the required prompt appears. A good tutorial can be seen here.

share|improve this answer


Development/Tutorials/Shell Scripting with KDE Dialogs :

 Example 6: Password Dialog Using a Shell Variable

 Instead of saving the result in a file, you can also use a shell
 variable. Note that you need to use the "backtick" notation - this key
 is normally found on the top left of English (British or American)
 layout keyboards, above the "7" key on French layout keyboards, and on
 the top right of German layout keyboards.

 password=`kdialog --password "Enter the password"`
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.