Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

BR,

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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)'"
share|improve this answer
    
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

 
discard

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.