[Gambas-user] Delete a file requiring Admin privilege

Tobias Boege taboege at ...626...
Fri Feb 1 23:47:39 CET 2013


On Fri, 01 Feb 2013, John Rose wrote:
> I want (in Gambas3) to delete a file in e.g. /usr/share/applications. 
> sInstallPath may have spaces in its filename: that's why I used a single 
> quote round it.
> 
> I've tried
> Exec ["gksudo", "rm", "'" & sInstallPath & "'"]
> which doesn't give an error but doesn't delete the file.
> 
> I've tried
> Exec ["gksudo rm", "'" & sInstallPath & "'"]
> which gives an error saying that the child program/process is not found 
> and doesn't delete the file.
> 
> How do I code this (without using Shell) so that there are no errors and 
> the file is deleted?

It's necessary to understand how Exec works: you give an array of individual
arguments to a program to execute (the first element in the array).

Do you have a program that is called "gksudo rm"? I suppose you want to
execute the program "gksudo" and give "rm" as an argument:

Exec ["gksudo", "rm", ...]

Concerning the path, again, do you have a file which is literally called

'/usr/share/applications/file'

? I suppose that you actually want to delete something like

/usr/share/applications/file

without quotes because those are most probably not part of its name.

Exec is not the shell. It doesn't need quoting but a strict separation of
arguments.

However, the final call to Exec would be:

Exec ["gksudo", "rm", sInstallPath]

But note that I don't know how gksudo behaves. This line may actually be
wrong for the semantics of the program. You'll know better...

Regards,
Tobi




More information about the User mailing list