From 7d4193b68eec17398476b3ae3e01ce81239d14c7 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Mon, 20 Jan 2014 14:20:14 +0100 Subject: [PATCH] modified web commands to run in apache and httpi --- web/htdocs/apacheEnv.pm | 7 +++++++ web/htdocs/commands/get.pl | 18 +++++++++++++----- web/htdocs/commands/getmultreg.pl | 16 ++++++++++++---- web/htdocs/commands/getpadiwa.pl | 20 ++++++++++---------- web/htdocs/commands/nettrace.pl | 17 ++++++++++++----- web/htdocs/commands/put.pl | 16 +++++++++++----- web/htdocs/commands/putbit.pl | 15 ++++++++++++--- web/htdocs/commands/spiexec.pl | 14 ++++++++++++-- web/htdocs/index.pl | 1 + 9 files changed, 90 insertions(+), 34 deletions(-) create mode 100644 web/htdocs/apacheEnv.pm diff --git a/web/htdocs/apacheEnv.pm b/web/htdocs/apacheEnv.pm new file mode 100644 index 0000000..c2f5987 --- /dev/null +++ b/web/htdocs/apacheEnv.pm @@ -0,0 +1,7 @@ +#!/usr/bin/perl +#This file sets the environment in case that the daqtools are run within an Apache web-server. + +$ENV{'DAQOPSERVER'} = 'jspc55:88'; + + +1; \ No newline at end of file diff --git a/web/htdocs/commands/get.pl b/web/htdocs/commands/get.pl index aaa9a4d..962c9e7 100755 --- a/web/htdocs/commands/get.pl +++ b/web/htdocs/commands/get.pl @@ -1,10 +1,18 @@ -&htsponse(200, "OK"); -print "Content-type: text/html\r\n\r\n"; - - - +#!/usr/bin/perl +use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use HADES::TrbNet; use Data::Dumper; +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { + print "HTTP/1.0 200 OK\n"; + print header("text/html"); + } +else { + use lib '..'; + use if (!($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i)), apacheEnv; + print "Content-type: text/html\n\n"; + } + + if (!defined &trb_init_ports()) { die("can not connect to trbnet-daemon on the $ENV{'DAQOPSERVER'}"); diff --git a/web/htdocs/commands/getmultreg.pl b/web/htdocs/commands/getmultreg.pl index 3261120..6e8c132 100755 --- a/web/htdocs/commands/getmultreg.pl +++ b/web/htdocs/commands/getmultreg.pl @@ -1,10 +1,18 @@ -&htsponse(200, "OK"); -print "Content-type: text/html\r\n\r\n"; +#!/usr/bin/perl +use HADES::TrbNet; +use Data::Dumper; +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { + print "HTTP/1.0 200 OK\n"; + print header("text/html"); + } +else { + use lib '..'; + use if (!($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i)), apacheEnv; + print "Content-type: text/html\n\n"; + } -use HADES::TrbNet; -use Data::Dumper; if (!defined &trb_init_ports()) { die("can not connect to trbnet-daemon on the $ENV{'DAQOPSERVER'}"); diff --git a/web/htdocs/commands/getpadiwa.pl b/web/htdocs/commands/getpadiwa.pl index 856d962..930ed05 100755 --- a/web/htdocs/commands/getpadiwa.pl +++ b/web/htdocs/commands/getpadiwa.pl @@ -1,15 +1,15 @@ -#!/usr/bin/perl -w - -eval{ - &htsponse(200, "OK"); - print "Content-type: text/html\r\n\r\n"; - }; - - - +#!/usr/bin/perl use HADES::TrbNet; use Data::Dumper; - +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { + print "HTTP/1.0 200 OK\n"; + print header("text/html"); + } +else { + use lib '..'; + use if (!($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i)), apacheEnv; + print "Content-type: text/html\n\n"; + } if (!defined &trb_init_ports()) { diff --git a/web/htdocs/commands/nettrace.pl b/web/htdocs/commands/nettrace.pl index 7396b29..6080da8 100755 --- a/web/htdocs/commands/nettrace.pl +++ b/web/htdocs/commands/nettrace.pl @@ -1,11 +1,18 @@ -#!/usr/bin/perl -w -&htsponse(200, "OK"); -print "Content-type: text/html\r\n\r\n"; - - +#!/usr/bin/perl use Date::Format; use HADES::TrbNet; use Data::Dumper; +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { + print "HTTP/1.0 200 OK\n"; + print header("text/html"); + } +else { + use lib '..'; + use if (!($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i)), apacheEnv; + print "Content-type: text/html\n\n"; + } + + if (!defined &trb_init_ports()) { die("can not connect to trbnet-daemon on the $ENV{'DAQOPSERVER'}"); diff --git a/web/htdocs/commands/put.pl b/web/htdocs/commands/put.pl index 6d2d6fe..f60b504 100755 --- a/web/htdocs/commands/put.pl +++ b/web/htdocs/commands/put.pl @@ -1,11 +1,17 @@ -&htsponse(200, "OK"); -print "Content-type: text/html\r\n\r\n"; - - - +#!/usr/bin/perl use HADES::TrbNet; use Data::Dumper; +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { + print "HTTP/1.0 200 OK\n"; + print header("text/html"); + } +else { + use lib '..'; + use if (!($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i)), apacheEnv; + print "Content-type: text/html\n\n"; + } + if (!defined &trb_init_ports()) { die("can not connect to trbnet-daemon on the $ENV{'DAQOPSERVER'}"); } diff --git a/web/htdocs/commands/putbit.pl b/web/htdocs/commands/putbit.pl index 813ed54..f4e6559 100755 --- a/web/htdocs/commands/putbit.pl +++ b/web/htdocs/commands/putbit.pl @@ -1,6 +1,15 @@ -#!/usr/bin/perl -w -&htsponse(200, "OK"); -print "Content-type: text/html\r\n\r\n"; +#!/usr/bin/perl +use HADES::TrbNet; +use Data::Dumper; +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { + print "HTTP/1.0 200 OK\n"; + print header("text/html"); + } +else { + use lib '..'; + use if (!($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i)), apacheEnv; + print "Content-type: text/html\n\n"; + } diff --git a/web/htdocs/commands/spiexec.pl b/web/htdocs/commands/spiexec.pl index e372cb4..f23d295 100755 --- a/web/htdocs/commands/spiexec.pl +++ b/web/htdocs/commands/spiexec.pl @@ -1,5 +1,15 @@ -&htsponse(200, "OK"); -print "Content-type: text/html\r\n\r\n"; +#!/usr/bin/perl +use HADES::TrbNet; +use Data::Dumper; +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { + print "HTTP/1.0 200 OK\n"; + print header("text/html"); + } +else { + use lib '..'; + use if (!($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i)), apacheEnv; + print "Content-type: text/html\n\n"; + } diff --git a/web/htdocs/index.pl b/web/htdocs/index.pl index fa3b5d4..9925f91 100755 --- a/web/htdocs/index.pl +++ b/web/htdocs/index.pl @@ -5,6 +5,7 @@ if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { } else { print "Content-type: text/html\n\n"; + use if (!$ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i), apacheEnv; } -- 2.43.0