PDA

View Full Version : Nautilus Scripting Questions



fatsheep
October 12th, 2006, 11:17 PM
I think I did a pretty bad job of explaining my problem in the last topic so I'll try again:

Nautilus scripts get passed three parameters that are of use to me: $NAUTILUS_SCRIPTS_SELECTED_URIS, $NAUTILUS_SCRIPTS_SELECTED_FILE_PATHS, and $NAUTILUS_SCRIPT_CURRENT_URI.

The names of the variables should explain what they are but if not, I made a nautilus script that simply displays the value of these variables. When I right click on a file named "Clear Trash" on my desktop and run the script, here are the values for these variables:

$NAUTILUS_SCRIPTS_SELECTED_URIS = file://home/ubuntu/Desktop/Clear%20Trash
$NAUTILUS_SCRIPTS_SELECTED_FILE_PATHS = /home/ubuntu/Desktop/Clear Trash
$NAUTILUS_SCRIPT_CURRENT_URI = file:///home/ubuntu/Desktop

Now here's the goal of my script: to execute Clear Trash with root permissions. I've tried the "sudo $NAUTILUS_SCRIPTS_SELECTED_URIS" and "sudo NAUTILUS_SCRIPTS_SELECTED_FILE_PATHS" commands. Neither works. HOWEVER, I have another script with the command "gksudo gedit $
NAUTILUS_SCRIPTS_SELECTED_URIS" and it works flawlessly.

If


gksudo gedit file://home/ubuntu/Desktop/Clear%20Trash

opens the file "Clear Trash" in gedit with root permissions then why does the commmand


sudo file://home/ubuntu/Desktop/Clear%20Trash

return the error


sudo: file://home/ubuntu/Desktop/Clear%20Trash: command not found

??? :confused:

po0f
October 13th, 2006, 03:50 AM
fatsheep,

Does the script have execute permission? Obviously you can read from and write to it, but can you execute it? Right-click on the script and check it's permissions.

fatsheep
October 13th, 2006, 08:40 PM
Yes the file is executable. If it were not then it wouldn't even show up in the scripts menu under nautilus.