From: ijackson Date: Tue, 22 Jun 1999 16:30:32 +0000 (+0000) Subject: Invocation improvements. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=f778de5ce78b6ddc1a36d0910494714bcd2bb28c;p=bcp5-registry.git Invocation improvements. --- diff --git a/bcp5-registry.pl b/bcp5-registry.pl index 4861b28..60a79bd 100755 --- a/bcp5-registry.pl +++ b/bcp5-registry.pl @@ -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'; diff --git a/run-from-lynx b/run-from-lynx index 8446672..29bb3d7 100755 --- a/run-from-lynx +++ b/run-from-lynx @@ -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