1.) Your situation is not related to the open
command. Before one can pass a remote share filepath as part of an argument, the share must first be established at a mount point. Here's an illustration to show what happens--or doesn't happen--using the simplest of commands:
ls smb://myshare._smb._tcp.local/path/to/file/my_file.pdf
Indeed, referencing a file in the manner you described--invoking its path via a mount request--causes that path to become a mount point. The Finder window you mentioned seeing:
... finder is opened with the last folder (/path/to/file) ...
represents the last known directory the system could use to create a mountable share. Run the command as you did, and look in /Volumes to see what I mean. It's likely not the share name you're used to seeing on that machine.
2.) When using open
as a command to launch an applications which is present in /Applications (or in ~/Applications), it's not necessary to provide its full path or its extension. Although the man pages would seem to indicate otherwise from their presentation, the command open -a Preview
is equivalent to open -a /Applications/Preview.app
3.) For that matter, if launch services associates a particular filetype with a default application--as with .pdfs and other image files with Preview, for example--it is not necessary to include the application name in the argument. The command open /path/to/my_file.pdf
is equivalent to open -a Preview /path/to/my_file.pdf
4.) I'm not all that clever when it comes to UNIX, so my following attempt at a solution will no doubt soon be improved by someone who has the skills I lack.
I'll start with the simplest way I know to mount a remote filesystem (it doesn't require creating a /dev node as with mount
or creating a mount point directory as with mount_smbfs
).
open smb://myshare._smb._tcp.local/share_name/
(quotes aren't necessary)
The share will be mounted in /Volumes, and you can open the file in Preview with this command:
open /Volumes/share_name/path_to_file/my_file.pdf
The two commands can be combined into a one-liner with &&
:
open smb://myshare._smb._tcp.local/share_name/ && open /Volumes/share_name/path_to_file/my_file.pdf
I tested all of the above [OS X 10.9.5], and unless I made a typo somewhere it should work. Good luck.
/Volumes/myshare
? As a workaround you could tryopen -a /Applications/Preview.app /Volumes/myshare/path/to/file/my_file.pdf
instead.Applications/Preview.app: is a directory
. @jaume - I want it to work when the share is not mounted - that is why I am passing the server path.