I try to open a file in gedit with the file-selection option of zenity. It's very easy to do it for file that i can access in normal mode, but I wanna open too some configuration files (as for exemple the conf files for vpnc) which are in a '700' folder (only the user root can read, write and execute the folder) I dont wanna change the permissions for the folder.

I tryed this :

gksudo -u root "gedit $(zenity --file-selection)"

but it didn't work

Is someone have an idea of how I can do it ?

Thx in advance folks



With the command you're running, the $(...) syntax is evaluated by your shell before calling gksudo. What you want is for it to be evaluated by a shell running as root. Perhaps try something like this:

gksudo -u root "sh -c 'gedit \$(zenity --file-selection)'"
  • Whoah, It's perfectly working...Thanks... OK I'll try to understand the command line. With gksudo -u root we subsitutte ourselve to the user root. I guess that with sh -c we invoke a new shell instance as user root, where we open gedit. Because gedit $(zenity --file-selection is the command sent to the new shell, we need to escape char '$'. That's right ? Thx a lot again James – Winael May 5 '11 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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