LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Nautilus Scripting Questions (https://www.linuxquestions.org/questions/programming-9/nautilus-scripting-questions-492221/)

fatsheep 10-13-2006 07:11 PM

Nautilus Scripting Questions
 
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 the files selected in nautilus 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.

So if the command,

Quote:

gksudo gedit file://home/ubuntu/Desktop/Clear%20Trash
opens the file "Clear Trash" in gedit with root permissions then why does the commmand,

Quote:

sudo file://home/ubuntu/Desktop/Clear%20Trash
return the error:

Quote:

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

schneidz 10-13-2006 07:50 PM

the first works because you are executing the program 'gedit'

the second, you may or may not be executing an executable

(what are you looking to do; do you just want root to be able to veiw the script?)

fatsheep 10-13-2006 09:06 PM

Quote:

Originally Posted by schneidz
the first works because you are executing the program 'gedit'

the second, you may or may not be executing an executable

(what are you looking to do; do you just want root to be able to veiw the script?)

I want to execute a file as root. The purpose of this script was to be used with installers that require root permissions. Normally you would have to go into the terminal cd to the installer directory and type "sudo <INSERT INSTALLER NAME HERE>". With the script you would just right click on the installer and select "Root Execute" from the nautilus script menu and it would install as root.

schneidz 10-14-2006 10:17 PM

i am not in front of my computer rite now but the way i remember it works is nautilaus reads scripts from a default directory (something like: ~home/user/nautilaus-scripts) so whenever you right-click on a file it shows up in the nautilaus scripts menu.

assuming 'clear trash' is the target script i would think the space is throwing it off. (you probably wouldn't be able to run it from the command line because of the space) try renaming it to something like clear-trash.ksh


All times are GMT -5. The time now is 02:22 PM.