chiark / gitweb /
Invocation improvements.
authorijackson <ijackson>
Tue, 22 Jun 1999 16:30:32 +0000 (16:30 +0000)
committerijackson <ijackson>
Tue, 22 Jun 1999 16:30:32 +0000 (16:30 +0000)
bcp5-registry.pl
run-from-lynx

index 4861b28d7fc4cc5977b60ec07ac479b76cb3d512..60a79bd4de7db91104d353d15f4aac5f61ab124e 100755 (executable)
@@ -1,14 +1,33 @@
 #!/usr/bin/perl
 
-system '(date;env) >debug.txt';
-
 use POSIX;
 
-if ($ENV{'BCP5REGISTRY_NOCGI'}) {
-    $scriptdir= '.';
+if ($ARGV[0] eq '--cgi') {
+    shift @ARGV;
+    $invokestyle= 'cgi';
+} elsif ($ENV{'SERVER_SOFTWARE'} =~ m/^Lynx/) {
+    $invokestyle= 'lynxcgi';
+} else {
     $invokestyle= 'manual';
+}
+
+if ($invokestyle eq 'manual') {
     open DEBUG,">&STDERR" or die $!;
+} elsif ($invokestyle eq 'lynxcgi') {
+    open DEBUG,">>debug.txt" or die $!;
+} elsif ($invokestyle eq 'cgi') {
+    open DEBUG,">/dev/null" or die $!;
+}
+
+if ($invokestyle eq 'cgi') {
+    $scriptdir= shift @ARGV;
+    $datadir= shift @ARGV;
 } else {
+    $scriptdir= '.';
+    $datadir= '.';
+}
+
+if ($invokestyle ne 'manual') {
     $ct= 'BCP5REGISTRY_CONTENTTYPEDONE';
     if (!$ENV{$ct}) {
        $|=1;
@@ -16,20 +35,11 @@ if ($ENV{'BCP5REGISTRY_NOCGI'}) {
        $|=0;
        $ENV{$ct}= 1;
     }
-
-    if ($ENV{'SERVER_SOFTWARE'} =~ m/Lynx/) {
-       open DEBUG,">>debug.txt" or die $!;
-       $scriptdir= '.';
-       $invokestyle= 'lynxcgi';
-    } else {
-       open DEBUG,"/dev/null" or die $!;
-       $scriptdir= $ENV{'SCRIPT_FILENAME'};
-       $scriptdir =~ s,/[^/]+$,,;
-       $invokestyle= 'cgi';
-    }
 }
 
-chdir($scriptdir) or die $!;
+push @INC,$scriptdir;
+chdir($datadir) or die $!;
+
 require 'config.pl';
 require 'database.pl';
 require 'utils.pl';
index 84466726e01b8ca7dbd3190cef5022678c76f95b..29bb3d728d247d6920fc3d07c6778e8c73e59b98 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 set -e
-exec lynx -cfg=/dev/null "$@" lynxcgi:./bcp5-registry.pl
+exec lynx -cfg=/dev/null -nocolor "$@" lynxcgi:./bcp5-registry.pl