I am writing an application that needs to be able to parse a path that is dragged from a remote server onto the command line. However, when I drag a path from a remote machine to the terminal I get something that looks like the following:

/home/user/.gvfs/sftp for Name on server-alias/the/full/path/is/here.file.

I would like just


to be parsed. I was wondering if there's a setting I can tweak to prevent this extra path prefix (preferable) or if there's some built in functionality somewhere in linux to do this. I can of course use regexs to parse this, but I would like to avoid that if possible.

I'm on ubuntu 10.04 LTS.

1 Answer 1


You might want to take a look at this tutorial titled: Scripting the Linux desktop, Part 2: Scripting Nautilus, which discusses how to add your own items to Nautilus' right click context menu as well as which variables Nautilus provides you when manipulating/dragging objects around inside of it.


Variables presented in Nautilus.

Environment variable                  Description
--------------------                  -----------
NAUTILUS_SCRIPT_SELECTED_FILE_PATHS   Newline-delimited paths for selected files (only if local)
NAUTILUS_SCRIPT_SELECTED_URIS         Newline-delimited URIs for selected files
NAUTILUS_SCRIPT_CURRENT_URI           The current location
NAUTILUS_SCRIPT_WINDOW_GEOMETRY       The position and size of the current window

In Python, you obtain the value of these variables with a single call to the os.environ.get function as follows:

selected = os.environ.get('NAUTILUS_SCRIPT_SELECTED_FILE_PATHS,'')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .