I am currently trying to connect my NAS on OSX 10.9.5 using the command line. This will work fine if I first connect my NAS using Finder: I select it in the "Shared" section of Finder's sidebar, click "Connect" and it will connect using the credentials from the keychain and list all available shares.
Then I can use mount_afp on the command line to mount my shares. However, without performing this step in Finder, the following will occur:
$ mount_afp afp://MyNAS._afpovertcp._tcp.local/my_share /path/to/mount_point mount_afp: AFPMountURL returned error -5002, errno is -5002
How can I perform the "connect" operation from Finder on the command line?