Escape special characters in mount command

16,576

Solution 1

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#[email protected]/myproject' ~/localmap

Solution 2

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

Solution 3

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

Solution 4

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
Share:
16,576
Karthick
Author by

Karthick

Doing development of C,C++, VC++, VB6, VB.net, C# applications for Windows applications, Embedded applications and Web applications. Knowledge of Windows, and Linux operating systems

Updated on June 16, 2022

Comments

  • Karthick
    Karthick almost 2 years

    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:[email protected]/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#[email protected]/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