Escape special characters in mount command

I am trying to install a Windows shared folder on Mac OSX Mavericks. Simple username and password worked fine

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

When checking for a more valid username and password, I get errors related to the URL parsing error. Details Username: mydomain \ user1 Password: A% b $ c @d! E # f

Tried the team

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

Based on what I found, $ and! must be avoided. Need help on how to avoid special characters. By the way, using only a username without a domain seems to work in the first case

+5
source share
5 answers

Single quotes shell metacharacters, semicolons should separate the domain controller from credentials and use %40 to enter @ in the password:

 mount -t smbfs '//mydomain;user1:A%b$c%40d!e# f@server1.mydomain.com /myproject' ~/localmap 
+4
source

Use \ to call special characters if you want to convert some special characters, you can write an additional line, where $ 1 is the parameter that you provide for conversion

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

and then you can use " " and call the converted variable as follows: $user1

+2
source

Just encode special characters.

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

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

eg.

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

Then this should work for you:

 mount -t smbfs //someone:passw% 40rd@server /path /Volumes/path 
+2
source

It may be convenient to use nodejs to encode url stuff:

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

Decode the other way:

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

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

0
source

Source: https://habr.com/ru/post/1207248/


All Articles