Connecting to a LAN machine/server - elegant method?

Simplest routine, I'm on machine_1 and I want to do a cmd-K style connect-to-server to machine_2 and then open a specific directory (fixed/constant/unchanging) on machine_2 as a tab in Path Finder. Ridiculously easy, right?

I have a solution but it's full of long/horrible Pause/Waits. I know this is NetAuthAgent stuff, which is a hidden-style app and regular Wait Until commands don't seem to apply. Currently, I have:

  • Path Finder, cmd-K, pause
  • (desired volume is always the only one listed) hit enter, 12 second pause
  • enter credentials, 12 second pause
  • select server scope, 3 sec pause
    Go to folder subroutine:
  • Path Finder 'Go' command does the job if using Unix-format directory path

... the 12 sec pauses above are to allow for variant system behaviour based on what's going on where you need worst-case scenarios (or else be frustrated).

Looking for a most-elegant solution:

  • Keyboard Maestro-only
  • KM/AppleScript
  • KM/Terminal
    ... open to any ideas. the only real challenge here is to test if the machine_2 mounted volume is present before accessing the desired directory.

Kind thanks in advance.

Did you ever get a response or find a more elegant method?

Connecting to a server is a simple one-line AppleScript:

open location URL

...and you set URL to what you want to do, as a string, in the form "protocol://username[:password]@address/sharename/folder".

Obviously, including the account password in a saved script is not recommended! But it's OK in certain situations, eg I've an iMac at home which everyone knows the password to and isn't accessible from the outside, so on my laptop I can use:

open location "smb://nige:fakepasswd@iMac-2.local/nige/Desktop" open the Desktop folder of the share "nige".

Note: if you're targeting a Mac and have turned on Sharing, user folders are shares, which is why that works. If you've something like a Synology you'll have set up named shares. Basically, attempt to connect from your Mac manually in the Finder in the usual way, using the username and password you'll use in the script, and you'll see the list of shares presented -- copy the name of the one you want and use it in your script.

"iMac-2.local" is the "Computer Name", as found in System Preferences->Sharing. You can also use an IP address or FQDN for external resources. The app used for the connection is your system's default for the protocol -- Finder for SMB/AFP, your default web browser for HTTP/HTTPS, etc. Note that the path to the folder should be URL encoded, eg if there's a space in a directory name, replace that with "%20" in the URL.

Pop the line above, edited appropriately, into a KM "Execute AppleScript" action and see how you go!

i did indeed! see nige_s reply above.

Nige - thank you! This is beautiful! Was so sick of Path Finder's iffy connections.