Date: Thu, 26 Jun 2003 23:16:12 -0400 From: parv <parv_fm@emailgroups.net> To: f-questions <freebsd-questions@freebsd.org> Subject: Re: mozilla is started instead of genuine netscape while opening a new window Message-ID: <20030627031612.GA92994@moo.holy.cow> In-Reply-To: <20030619074104.GA70732@moo.holy.cow> References: <20030619074104.GA70732@moo.holy.cow>
next in thread | previous in thread | raw e-mail | index | archive | help
in message <20030619074104.GA70732@moo.holy.cow>, wrote parv
thusly...
>
> Problem does not happen when the genuine netscape is not running.
> In that case, it is started anew.  In addition, mozilla doesn't
> start if its is not already running.
> 
> Say, i have /both/ mozilla & netscape running.  If i want to open
> a new window of the genuine netscape, thru netscape-wrapper,
> a mozilla window is opened instead of navigator's.
Since nobody has replied, allow me to share the /workaround/, not a
real solution to the problem, which calls "netscape", from
netscape-wrapper port, only when mozilla is not
An optional URI is the only argument it takes/uses on the command
line.  It assumes that linux-netscape-navigator-4.8 port has been
installed.
  #!/usr/local/bin/perl -w
  use strict;
  #  regex to identify desired processes in ps output
  my $moz =
    { 're' => qr/^ [^\s]+ \b mozilla-bin \b/x
    , 'exists' => 0
    };
  my $netscape =
    { 're' => qr/^ [^\s]+ \b navigator-linux-\d+\.\d+\.bin \b/x
    , 'exists' => 0
    };
  exec_netscape( $moz , $netscape );
  sub exec_netscape
  { my ($moz , $netscape) = @_;
    #  "⊂" usage is INTENTIONAL
    &find_proc;
    my @ex;
    push @ex
      , $moz->{'exists'} ? 'navigator-linux-4.8' : 'netscape'
      ;
    if ($netscape->{'exists'})
    { push @ex
        , qw{ -irix-session-management -remote }
        , ( !scalar @ARGV
            ? qw{ 'xfeDoCommand(openBrowser)' }
            : qw{ 'openURL( }
              . +(shift @ARGV)
              . " , new-window)'"
          )
        ;
    }
    system "@ex &"
      and die "@ex failed: $? $!\n";
  }
  sub find_proc
  { my @proc = qx/ps -axww/ or die "'ps -axww'  failed: $!\n";
    chomp @proc;
    foreach my $h (@_)
    { next if $h->{'exists'};
      foreach my $p (@proc)
      { last if $h->{'exists'};
        ++$h->{'exists'}
          if (split ' ' , $p , 5 )[-1] =~ m/ $h->{'re'} /x;
      }
    }
  }
  __END__
Happy programming!
  - Parv
-- 
A programmer, budding Unix system administrator, and amateur photographer
ISO employment...
  http://www103.pair.com/parv/work/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030627031612.GA92994>
