[Gambas-user] kdesu vs gksu

Jose J. Rodriguez joe1962 at ...626...
Tue May 19 20:53:04 CEST 2009


On 5/18/09, Jesus Guardon <jguardon at ...2035...> wrote:
> Yes, I know it may be a little off-topic, but the question is:
>
>  I need to launch a process with root privileges from SHELL command in
>  Gambas. Users of my application can have Gnome or KDE, so I don't know
>  which command I must issue to get it to work.
>
>  Is there a way to choose between either gksu o kdesu commands at runtime?
>  I've figured it out if it could be something like:
>
>   SHELL "gksu | kdesu -u root 'some_command'"
>
>  or
>
>  SHELL "gksu -u root 'some_command' | kdesu -u root 'some_command'"
>

Here's what I do in the vl-hot-config utility:

*******************************************************
' Gambas module file

PUBLIC SUB Main()
DIM MyProc AS Process
DIM Ret AS String

IF System.User.Id <> 0 THEN
   EXEC ["which", "kdesu"] TO Ret
   IF InStr(Ret, "kdesu") THEN
      EXEC ["kdesu", Application.Path &/ "vl-hot-config.gambas"]
   ELSE
      EXEC ["which", "gksu"] TO Ret
      IF InStr(Ret, "gksu") THEN
         EXEC ["gksu", Application.Path &/ "vl-hot-config.gambas"]
      ELSE
         PRINT "No kdesu or gksu available (vl-hot-config needs to run
as root)..."
      ENDIF
   ENDIF
   QUIT
ENDIF

FMain.Show

END
*******************************************************

Regards,
Joe1962




More information about the User mailing list