From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22403 invoked from network); 21 Jun 2000 16:27:52 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Jun 2000 16:27:52 -0000 Received: (qmail 4240 invoked by alias); 21 Jun 2000 16:27:15 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3196 Received: (qmail 4193 invoked from network); 21 Jun 2000 16:27:11 -0000 Date: Thu, 22 Jun 2000 02:12:56 +1000 From: Shao Zhang To: ZSH Mail List Cc: Bart Schaefer Subject: Re: [OT] export http_proxy Message-ID: <20000622021256.A6423@localhost> References: <20000616023433.A7142@localhost> <20000622015151.A6048@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20000622015151.A6048@localhost>; from shao@linux.cia.com.au on Thu, Jun 22, 2000 at 01:51:52AM +1000 Sender: Shao Zhang Hi, Sorry, I thought I had a perfect solution, but I am still not quite there yet. My problem is, when I do a killall -USR2 zsh, all the existing zsh shells will be able to catch the signal and then export the http_proxy properly. Now, this fails when I open up a new xterm, is there anyway to allow all the zsh process to share certain shell variables? THanks. Shao. Shao Zhang [shao@linux.cia.com.au] wrote: > Bart Schaefer [schaefer@brasslantern.com] wrote: > > On Fri, 16 Jun 2000, Shao Zhang wrote: > > > > > I have a couple of isps on my linux box, and some of them need a > > > proxy setting. So nearly everytime I dial up, I have to export the > > > http_proxy in order to use it. Now is there an easy/smart way to do > > > this rather than doing it manually? > > > > Use the `preexec' user-defined function. You need to devise a test that > > zsh can use to determine to which ISP you're presently connected; perhaps > > something like > > > > function preexec() { > > case ${${(M)$(ifconfig ppp0):#addr:*}#addr:} in > > 192.168.68.1) export HTTP_PROXY=192.168.68.215;; > > 192.168.86.9) typeset +x HTTP_PROXY; unset HTTP_PROXY;; > > and-so-on) export HTTP_PROXY=and-so-forth;; > > esac > > } > > > > However, it might be a bit expensive to run ifconfig before each and every > > command, so you might instead try putting it in the `periodic' function > > (so it gets updated every $PERIOD seconds, which you also need to set). > > Thanks. I don't know both preexec and periodic before, it is very > usefull to know for my other stuff. But preexec is a bit expensive, > and periodic does not really fit well since I only really need to > update the proxy settings once. > > > Or you could put it in a trap handler for e.g the USR2 signal and have a > > script that runs when PPP comes up that does a "killall -USR2 zsh" to > > cause all shells to update their environment. > > Thanks again. This is my perfect solution. Putting an extra line > killall -USR2 zsh in the ip-up script made it all happen. > > Also, I am just wondering, are all these features unique to zsh, or > other shells have got them as well? > > Thanks. > > Shao. > > -- > ____________________________________________________________________________ > Shao Zhang - Running Debian 2.1 ___ _ _____ > Department of Communications / __| |_ __ _ ___ |_ / |_ __ _ _ _ __ _ > University of New South Wales \__ \ ' \/ _` / _ \ / /| ' \/ _` | ' \/ _` | > Sydney, Australia |___/_||_\__,_\___/ /___|_||_\__,_|_||_\__, | > Email: shao@cia.com.au |___/ > _____________________________________________________________________________ -- ____________________________________________________________________________ Shao Zhang - Running Debian 2.1 ___ _ _____ Department of Communications / __| |_ __ _ ___ |_ / |_ __ _ _ _ __ _ University of New South Wales \__ \ ' \/ _` / _ \ / /| ' \/ _` | ' \/ _` | Sydney, Australia |___/_||_\__,_\___/ /___|_||_\__,_|_||_\__, | Email: shao@cia.com.au |___/ _____________________________________________________________________________