Blog

03/06/2019

Set/Export: http_proxy With Special Characters In Password Under Unix / Linux



My proxy server password has special characters such as !,@, and so on. How do I set and export the variable called http_proxy or HTTP_PROXY when password has special characters under Unix like operating systems?

If your password is F@o:o!B#ar$ and set http_proxy as follows:

export http_proxy="http://user:F@oo!B#ar$@server1.sxi.io:3128/"

You may get the error due to special characters. The solution is to use unicode characters in hexadecimal. You can use command line tool such as unum or gnome-character-map to convert special characters into hexadecimal unicode.

Example

Convert @:!#$ into equivalent hexadecimal unicode using unum command:
$ unum '@:!#$'
Sample outputs:

   Octal  Decimal      Hex        HTML    Character   Unicode
    0100       64     0x40       @    "@"         COMMERCIAL AT
     072       58     0x3A       :    ":"         COLON
     041       33     0x21       !    "!"         EXCLAMATION MARK
     043       35     0x23       #    "#"         NUMBER SIGN
     044       36     0x24       $    "$"         DOLLAR SIGN

In this example @ becomes %40, : becomes %3A, and so on. Find and replace all special characters with unicode hexs. Find:
F@o:o!B#ar$
Replace with:
F%40o%3Ao%21B%23ar%24
Finally, set and export http_proxy, HTTP_PROXY in the following format:

export http_proxy="http://user:F%40o%3Ao%21B%23ar%24@server1.sxi.io:3128/"

Test it:
$ curl -I sxi.io
$ wget http://sxi.io/

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

20/08/2019

Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...
14/08/2019

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...
14/08/2019

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....