[Gambas-user] Delete a file requiring Admin privilege

Tobias Boege taboege at ...626...
Sun Feb 3 16:39:07 CET 2013


On Sun, 03 Feb 2013, John Rose wrote:
> I've just tried using Exec with "gksudo" and having only one 
> concatenated parameter:
> Exec ["gksudo", "desktop-file-install " & "--dir=" & sInstallDirectory & 
> " " & sPath] To sOutput
> 
> It gave no errors but it didn't work.
> 
> I was using Shell and that worked with Shell$ applied to the directory 
> and path variables above. But I thought that I'd try using Exec as the 
> equivalent gksudo command to the above can be run in Terminal i.e. not 
> using bash.

So, putting it all together, I _suppose_ that the following happens:

- gksudo takes the command to execute and all its parameters in one single
  argument.
- it elevates its privileges and calls the shell to execute the command
  given.

Consequently the following may work:

Exec ["gksudo", Shell$("desktop-file-install " & Shell$(sPath))]

I read about some hacks in the code which would allow you to use "--" to
separate arguments to gksudo and the program being called. Maybe you can
experiment a little bit if the above does not work (I fear it). If, on the
other side, it does work, then I would suggest using the Shell instruction
instead of Exec :-)

Regards,
Tobi




More information about the User mailing list