9

I am trying to mount a windows shared folder on Mac OSX Mavericks. A simplistic user name and password worked fine

mount -t smbfs //user2:password2@server1.mydomain.com/myproject ~/localmap

On trying out the more valid user name and password I am getting errors that parsing URL failed. The details are Username: mydomain\user1 Password: A%b$c@d!e#f

The command tried is

mount -t smbfs //mydomain\user1:A%b\$c\@d\!e#f@server1.mydomain.com/myproject ~/localmap

Based on what I found, $ and ! needs to be escaped. Need help on how to escape the special characters. Incidentally, using only the username without the domain seems to work in the first case

Karthick
  • 255
  • 1
  • 4
  • 13
  • I see you have escapes (`\`) in the command you tried. What error are you getting? – bishop Nov 19 '14 at 20:35
  • Here is the error message `mount_smbfs: URL parsing failed, please correct the URL and try again: Invalid argument` – Karthick Nov 19 '14 at 20:42

5 Answers5

7

Just encode your special characters.

@ -> %40
$ -> %24
! -> %21 

Others characters can be found here: http://www.degraeve.com/reference/urlencoding.php

e.g.

username="someone", password="passw@rd"

Then this should work for you:

mount -t smbfs //someone:passw%40rd@server/path /Volumes/path
Longfei Wu
  • 617
  • 7
  • 9
6

Single quotes escape shell meta-characters, a semi-colon should separate the domain controller from the credentials, and can use %40 to represent an @ in the password:

mount -t smbfs '//mydomain;user1:A%b$c%40d!e#f@server1.mydomain.com/myproject' ~/localmap
bishop
  • 32,403
  • 9
  • 89
  • 122
  • 1
    The single quote and the semi colon are fine but the special characters in the password are still giving the same error message. – Karthick Nov 19 '14 at 21:15
  • I suspect it is the @ symbol since it is used to separate the password from the server name – Karthick Nov 19 '14 at 21:24
  • Yeah, yikes. Made an edit, give that a whirl. The next level of fix is not pretty.... – bishop Nov 19 '14 at 21:36
2

Use \ to escape special symbols if you want to convert some special symbols you can write additional string, where $1 - is parameter you provide for converting

user1=$(sed -e "s/+/%2B/g;s/@/%40/g;s/_/%5F/g" <<< "$1")

and then you can use " " and call your converted variable like this $user1

midori
  • 4,459
  • 5
  • 26
  • 57
2

Might be handy to use nodejs to encode the url stuff:

$ node -e 'console.log(encodeURIComponent("A%b$c@d!e#f"))'
A%25b%24c%40d!e%23f

Decode to go the other way:

$ node -e 'console.log(decodeURIComponent("A%25b%24c%40d!e%23f"))'
A%b$c@d!e#f
rigglesbee
  • 98
  • 3
0

Please see https://serverfault.com/questions/309429/mount-cifs-credentials-file-has-special-character, the first answer there worked for me. Basically, you create a file with the credentials and then specify that file instead of your username and password.

the_ccalderon
  • 1,568
  • 2
  • 8
  • 20