I just got a job where I'll be spending the day behind a firewall. By night I'll carry my laptop home and do my meditations outside the firewall. I wrote the following scripts to avoid the hassle of setting my proxy preferences by hand twice a day:
No proxy: #!/bin/sh perl -pi -e 's/^user_pref\("network\.proxy\.type".+$//' ~/.netscape/pr +eferences.js netscape& Yes proxy (no perl!): #!/bin/sh echo 'user_pref("network.proxy.type", 1);' >> ~/.netscape/preferences. +js netscape&

Replies are listed 'Best First'.
RE: no proxy - yes proxy Netscape
by Anonymous Monk on May 23, 2000 at 03:25 UTC
    Why not use sed instead of perl for this?
RE: no proxy - yes proxy Netscape
by rjimlad (Acolyte) on May 25, 2000 at 21:46 UTC
    Nice little trick, but I'm sure the first could be written as a pure perl script (I don't like the idea of launching an interpreter from an interpreter). Of course, I can't be bothered to... because I can't remember an easy way of doing a read and a write at (about) the same time. *sigh* ---- Arrr, Jim lad.
      Well, you could keep it a one-liner and call exec to run netscape, still taking advantage of the cool -pi options:
      perl -pi -e 's/^user_pref\("network\.proxy\.type".+$//; END{exec netsc +ape}' ~/.netscape/preferences.js