linux - proxy authentication using functions -


i followed arch wiki article create shell script file following functions:

#!/bin/bash function proxy(){      echo -n "username:"      read -e username      echo -n "password:"      read -es password      export http_proxy="http://$username:$password@proxyserver:8080/"      export https_proxy=$http_proxy      export ftp_proxy=$http_proxy      export rsync_proxy=$http_proxy      export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"      echo -e "\nproxy environment variable set."  }  function proxyoff(){      unset http_proxy      unset http_proxy      unset https_proxy      unset https_proxy      unset ftp_proxy      unset ftp_proxy      unset rsync_proxy      unset rsync_proxy      echo -e "\nproxy environment variable removed."  }  case "$1" in      'proxyon')               proxyon               ;;      'proxyoff')               proxyoff               ;;      *)# default execute               proxyon esac 

upon execution (as root , user) entered username password requested script above wasn't able see aliases being set!! printed 'printenv' see environmental variables. can point out folly.

don't execute script, source instead. execution happen in subshell , prevents see side-effects should caused script.

invoke script saying:

source /path/to/script 

or

. /path/to/script 

(note space between . , path in above line)


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -