Created
March 4, 2017 11:42
-
-
Save Odyno/36fb85fc46df020754f4d657524c9b7f to your computer and use it in GitHub Desktop.
Temporarily set the proxy in linux shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
odyssey@Itaca:/opt/bin/tmp$ cat set-proxy.sh | |
#!/bin/bash | |
# | |
# Copyright 2012 Alessandro Staniscia (email : alessandro@staniscia.net) | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License, version 2, as | |
# published by the Free Software Foundation.# | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software | |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
# | |
# Contributors: Alessandro Staniscia | |
# Stable tag: 0.1.1 | |
# License: GPLv2 | |
# License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
# URI: https://www.staniscia.net | |
# | |
# Description: | |
# Temporarily set the proxy in linux shell | |
PROXY_DEFAULT_NAME="proxydmz.trs.it" | |
PROXY_DEFAULT_PORT="3128" | |
PROXY_DEFAULT_USER="staniscia" | |
read -e -i "$PROXY_DEFAULT_NAME" -p "Please enter proxy hostname: " input | |
proxy_hostname="${input:-$PROXY_DEFAULT_NAME}" | |
read -e -i "$PROXY_DEFAULT_PORT" -p "Please enter proxy port: " input | |
proxy_port="${input:-$PROXY_DEFAULT_PORT}" | |
read -e -i "$PROXY_DEFAULT_USER" -p "Please enter username: " input | |
user="${input:-$PROXY_DEFAULT_USER}" | |
echo -n "Please enter password:" | |
stty -echo | |
read pwdr | |
stty echo | |
echo "" | |
export PROXYHOST="$user:$pwdr@$proxy_hostname:$proxy_port" | |
export http_proxy="http://$PROXYHOST" | |
export https_proxy="https://$PROXYHOST" | |
export ftp_proxy="ftp://$PROXYHOST" | |
export ftps_proxy="ftps://$PROXYHOST" | |
export proxy_user=$user | |
export proxy_passwd=$pwdr | |
echo "Hello $user, that's all!" | |
/bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment