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

You can set the http_proxy environment variable with a password that contains special characters by URL encoding the password. The URL encoding replaces special characters with their hexadecimal representation.

Here’s an example of setting the http_proxy variable with a password that contains special characters:

export http_proxy="http://username:$(echo -n "pass#word" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')@proxy.example.com:8080"

In this example, the password pass#word is URL encoded using xxd and tr commands. The resulting string is then included in the http_proxy variable.

Note: This method works with most Unix/Linux shells, but the exact syntax may vary depending on the shell you are using.

Leave a Comment