4
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Link
Name=ShareFolder
Icon=/usr/share/icons/DPL/NetworkShare.png
Name[en_US]=ShareFolder
URL=smb://servername/sharefolder

This is my .desktop file which has a URL. How do I execute this desktop shortcut in the terminal? If i double click it works perfectly, but I need to execute this in terminal.

I tried Running a .desktop file in the terminal. That didn't work for me either but it does if its an "application" shortcut. I'm trying here to execute "link" .desktop file, where you define in the type section (Type=Link) and (URL=smb://servername/sharefolder)

Pubudug
  • 41
  • 1
  • 4

1 Answers1

3

Use

xdg-open path/to/file.desktop

The first line in the file is the application that runs that file.

If this does not work, try this (adopted from Running a .desktop file in the terminal):

xdg-open `grep '^URL' path/to/file.desktop | tail -1 | sed 's/^URL=//' | sed 's/%.//'` &
Danatela
  • 13,243
  • 11
  • 45
  • 72
  • This way it wont work. it will open the .desktop file in edit mode.does not execute it. – Pubudug Jun 09 '14 at 07:27
  • This might be helpful: http://askubuntu.com/questions/5172/running-a-desktop-file-in-the-terminal – Danatela Jun 09 '14 at 07:32
  • i tried that article . that didn't work for me either but it does if its an "application" shortcut. im trying here to execute "link" .desktop file. where you define in the type section.(Type=Link) and (URL=smb://servername/sharefolder) – Pubudug Jun 09 '14 at 07:34
  • I edited answer, hope that will help. – Danatela Jun 09 '14 at 07:41
  • didn't work that either. What im trying to achieve here is URL link file to a share folder .(Type=Link) and (URL=smb://servername/sharefolder) – Pubudug Jun 09 '14 at 07:47
  • Does xdg-open smb://servername/sharefolder work? – Danatela Jun 09 '14 at 07:58
  • gvfs-open: smb://servername/sharefolder: error opening location: The specified location is not mounted. – Pubudug Jun 09 '14 at 08:08
  • Then it's better to use autofs and change URL to something like /smb/servername/sharedfolder. It has advantage that folder will be mounted automatically. – Danatela Jun 09 '14 at 08:21
  • that wont give me the share authorities exactly to the login user from the domain. it overrides with the mounting user authorities. if i put it in fstab thats going to take su access. – Pubudug Jun 09 '14 at 12:31
  • Not if you will use credentials file. I assume you are entering credentials each time you connect. The credentials file can bypass it. – Danatela Jun 09 '14 at 13:16