Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Set proxy environment variables automatically' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set proxy environment variables automatically
Authored by: fds on Jan 13, '04 02:28:24PM
Thanks, just what the doctor ordered! I've been thinking of writing something like this ever since I got my Mac (still less than a year ago.). :)
My gratitude for saving me the time to look up the information.

I modified the output ever so slightly to fit my needs better to


	if (GetHTTPProxySetting(host, sizeof(host), &port))
		printf("http_proxy=http://%s:%u/ ", host, port);
	if (GetHTTPSProxySetting(host, sizeof(host), &port))
		printf("https_proxy=http://%s:%u/ ", host, port);
	if (GetFTPProxySetting(host, sizeof(host), &port))
		printf("ftp_proxy=http://%s:%u/ ", host, port);
Then I just alias my wget etc. commands like this:

alias wget="`setproxy` wget"
So the proxy settings get refreshed automatically when I start a new wget process plus it only gets set for that specific process so there's no need for the unsets.

I use bash, I'm not sure if something like this is feasible with other shells.

Now we just need to figure out how to take into account the proxy exclusion list...

[ Reply to This | # ]

Set proxy environment variables automatically
Authored by: blalor on Jan 13, '04 03:39:49PM
actually, that alias doesn't work. It gets expanded when it is declared, instead of at excecution time. Try this, with the original setproxy: in ~/.bashrc:

my_wget() {
    eval $(setproxy)
    wget $*
}

alias wget='my_wget'


[ Reply to This | # ]
Set proxy environment variables automatically
Authored by: conall on Sep 03, '04 08:48:05PM

The exclusion list problem is easily solved, simply set the $no_proxy enviromental variable, eg
export no_proxy=.domain.com.


It works in bash at least, should be shell independant, since programs like curl and wget check for such variables...



[ Reply to This | # ]