Blaskovic
Blaskovic

Reputation: 356

Zenity entry and sudo -S not working properly without shell

I have problem with zenity entry and sudo -S.

I am doing something like this:

zenity --entry --title 'title' --text 'text' --hide-text | sudo -S pm-suspend

If I run this in shell, it's working. But I put it into file and I am launching this script with key shortcut. It's not working!

I've tried to replace pm-suspend with my own script, which prints id -u to file. But no file was created.

Any ideas, where could be a problem? Thank you

Upvotes: 0

Views: 1372

Answers (4)

There has been a kde-sudo package around for ages. Just look in your package manager for sudo. It will let you authenticate through a GUI. Doing it with a prompt-generator is really tacky.

So in you script you will do:

kdesudo
privilegedcommand

There is a similar thread on Superuser about this, perhaps someone has said something about gnome:

https://superuser.com/questions/135311/sudo-access-for-desktop-actions-in-gnome-kde

Upvotes: 0

David Va
David Va

Reputation: 11

It looks terrible but you could use:

xterm -e "zenity --entry --title 'title' --text 'text' --hide-text | sudo -S pm-suspend"

If anyone knows how to hide xterm, or another solution, please share.

Upvotes: 1

Blaskovic
Blaskovic

Reputation: 356

So I figured out, what was problem..

sudo is not running without tty. So it's necessary to edit /etc/sudoers file and delete requiretty line.

Upvotes: 0

Igor Chubin
Igor Chubin

Reputation: 64563

It depends on the (1) script and (2) the place where you run it.

For example, it is possible that your environment where you start the script has other PATH or other environment variable.

Can you please show the script and how do you start it?

Upvotes: 0

Related Questions