LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-13-2006, 07:11 PM   #1
fatsheep
Member
 
Registered: Sep 2006
Posts: 79

Rep: Reputation: 15
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
???

Last edited by fatsheep; 10-14-2006 at 11:25 AM.
 
Old 10-13-2006, 07:50 PM   #2
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 3,912

Rep: Reputation: 599Reputation: 599Reputation: 599Reputation: 599Reputation: 599Reputation: 599
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?)
 
Old 10-13-2006, 09:06 PM   #3
fatsheep
Member
 
Registered: Sep 2006
Posts: 79

Original Poster
Rep: Reputation: 15
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.
 
Old 10-14-2006, 10:17 PM   #4
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 3,912

Rep: Reputation: 599Reputation: 599Reputation: 599Reputation: 599Reputation: 599Reputation: 599
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Questions about Nautilus + ntfs in FC3 leduytien Linux - Software 0 10-25-2004 07:07 AM
a few scripting questions w/X promark Linux - Software 1 07-15-2004 12:34 AM
Naive scripting question (for Nautilus) the_rydster Programming 3 11-15-2003 02:58 PM
Naive scripting question (for Nautilus) the_rydster Linux - General 0 11-15-2003 10:58 AM
(More) questions about Nautilus burn:/// Jim Miller Linux - Software 0 08-16-2003 07:17 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration