I'm pretty new to bash scripting. I'm trying to make a script to export the http_proxy variables. This is what I do from the terminal:
$export http_proxy=http://proxy21.iitd.ernet.in:3128/
$export https_proxy=https://proxy21.iitd.ernet.in:3128/
This works just fine. Now, here's my script (called setproxy):
#!/usr/bin/env bash
if [ $1 -eq 22 ]
then
export http_proxy=http://proxy22.iitd.ernet.in:3128/
export https_proxy=https://proxy22.iitd.ernet.in:3128/
elif [ $1 -eq 21 ]
then
export http_proxy=http://proxy21.iitd.ernet.in:3128/
export https_proxy=https://proxy21.iitd.ernet.in:3128/
elif [ $1 -eq 61 ]
then
export http_proxy=http://proxy61.iitd.ernet.in:3128/
export https_proxy=https://proxy61.iitd.ernet.in:3128/
elif [ $1 -eq 62 ]
then
export http_proxy=http://proxy62.iitd.ernet.in:3128/
export https_proxy=https://proxy62.iitd.ernet.in:3128/
fi
Essentially, I want to set the appropriate proxy server depending on the input. I put it in the bin folder, made it executable, added bin to the path, logged in and out. The terminal accepts setproxy as a valid command (at leat there's no command not found error) But, when I do:
$setproxy 22
There is no effect. The proxy remains unchanged. What am I doing wrong?