Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curl - Exclamation mark in User Auth/Password

Having a problem with CURL and the HTTP User and password Auth methods, it is not liking the exclamation mark, I've tried escaping the following ways:

Tried and failed...

/usr/bin/curl -u 'UserName\WithSlash:PasswordWithExclamation!' https://test.com/ /usr/bin/curl -u UserName\\WithSlash:PasswordWithExclamation\! https://test.com/ 

Not working for basic or digest if it matters (using --anyauth) ... getting 401 denied...

What am I doing incorrectly?

like image 377
MichaelICE Avatar asked Jul 12 '12 02:07

MichaelICE


People also ask

How do I escape exclamation mark in bash?

Bash script (detect.sh) When an argument contains a special character (for example, an exclamation point) you must escape the character with a backslash. The backslash should precede the escaped character.

What does exclamation mark mean in Linux?

Overview. If we work a lot with the interactive Linux command line, chances are we might have come across the exclamation symbol. On most shells, this symbol is used to rerun previously executed commands through history expansion, thereby, increasing our productivity.


2 Answers

 curl -u UserName\\WithSlash:PasswordWithExclamation\!  http://.... 

works fine.

it sends

 GET / HTTP/1.1  Authorization: Basic VXNlck5hbWVcV2l0aFNsYXNoOlBhc3N3b3JkV2l0aEV4Y2xhbWF0aW9uIQ==  User-Agent: curl/7.21.0  Host: teststuff1.com:80  Accept: */* 

which is "UserName\WithSlash:PasswordWithExclamation!" in the auth string.

like image 68
pizza Avatar answered Sep 19 '22 14:09

pizza


not that complicated, just use "". at least it works on Linux.

for example:

curl -u "username:passwdwithspecialchar" GET https://.... 
like image 43
Shen Yong Avatar answered Sep 20 '22 14:09

Shen Yong