You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rob Hartill <ha...@ooo.lanl.gov> on 1996/02/16 05:36:03 UTC

global prefs for Netscape

I digress once more.

I was asked today if I knew how to set global preferences for Netscape,
so that the folks at Cardiff could be forced^H^H^H^H^H^Hencouraged
to use a proxy (hensa). According to the Netscape FAQ there's no way,
and they give a pretty useless (for existing users) script wrapper that
creates a prefs file if one doesn't exist already.

Here's what I came up with - not hacker-proof but certainly 
average-user-proof.

In this example, users are forced to use the proxy (at startup) and
their simultaneous connections get pushed down to 2 (heehee)

Maybe we can drop it into support? It'd be useful for admins wanting
to make use of the new proxy module :-)  (wow, I almost made this mail
relevant to Apache)

I haven't tested it (can't) on real lusers (other than luser #1 - me).
If anyone finds it useful, lemme know.

ta,
rob

-=-=-=-=-=-=-=-=-


#!/usr/local/bin/perl

# script to override Netscape user prefs with global prefs
#  Rob Hartill 1996

$GLOBAL{"HTTP_PROXY"} =	"www.lanl.gov:8002";
    # Force people to use a proxy
$GLOBAL{"NO_PROXY"} = "ooo.lanl.gov"; 
    # don't proxy the local server
$GLOBAL{"MAX_CONNECTIONS"} = 2;
    # make the local users a bit more network friendly by lowering
    #  their number of simultaneous connections to the net

$LUSER_CONFIG = "$ENV{HOME}/.netscape/preferences";
    # should be standard

$BINARY = "/usr/local/bin/netscape.binary";
    # where you keep the real binary for Netscape

################## nothing below needs changing ##################

if (-e "$LUSER_CONFIG") {
  $/ = undef;
  open(LUSER, "$LUSER_CONFIG") || warn "Can't read $LUSER_CONFIG";
  $luser_prefs = <LUSER>;
  close(LUSER);
}

$new_prefs = "";

foreach $line (split(/\n/, $luser_prefs)) {
   $new_prefs .= sprintf("%s\n", $line), next if $line !~ /\:/;
   
   ($pref, $val) = split(/\:\t*/, $line, 2);
 
   if (defined $GLOBAL{$pref}) {
      $line = "$pref:\t$GLOBAL{$pref}";
   }
   $new_prefs .= "$line\n";
}

if ($luser_prefs ne $new_prefs) {
   chmod(0600, $LUSER_CONFIG);
   rename($LUSER_CONFIG, $LUSER_CONFIG.".bak");
   open(LUSER, ">$LUSER_CONFIG") || warn "Can't write $LUSER_CONFIG";
   print LUSER $new_prefs;
   close(LUSER);
}

`$BINARY`;