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

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to