]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Added IPC::Run module to handle various STDOUT situations.
authorWill Budic <redacted>
Wed, 6 Nov 2019 20:03:39 +0000 (07:03 +1100)
committerWill Budic <redacted>
Wed, 6 Nov 2019 20:03:39 +0000 (07:03 +1100)
Installation.txt
htdocs/cgi-bin/stats.cgi

index 2150ddcbb39c92fd5eb21cbb5b7c9df0c5d7437d..364d6bb7675a3b55487051d4f050ec10571392b5 100644 (file)
@@ -96,6 +96,7 @@ sudo cpanm Number/Bytes/Human.pm;
 sudo cpanm Regexp::Common;
 sudo cpanm JSON;
 sudo cpanm Switch;
+sudo cpanm install IPC::Run
 
 #Install DBI module
 sudo cpanm DBI;
@@ -110,6 +111,9 @@ Platforms supported, Windows, Unix (all), Mac.
 Installing perl as an developer, requires no sudo. 
 But hence can't run server (system level) like.
 
+If developer and running perlbrew, recommended is to use
+cpan to install required modules.
+
 #Upgrade Instructions
 
 To upgrade to newer version of this software requires data migration.
index 7be5ae7438087ea9912402f374ac612c22276898..d91d7a3d2898dfdfd28d37f904768d989c4641d7 100755 (executable)
@@ -15,11 +15,7 @@ use DBI;
 use DateTime;
 use DateTime::Format::SQLite;
 use Number::Bytes::Human qw(format_bytes);
-my $HS;
-#perlbrew fix, with main::sub not recognised in inxi.pl
-BEGIN {
-  $HS = `inxi -b -c0; uptime -p`;
-}
+use IPC::Run qw( run );  
 
 
 #SETTINGS HERE!
@@ -29,6 +25,7 @@ my $LOG_PATH     = '../../dbLifeLog/';
 my $RELEASE_VER  = "";
 my $THEME        = 0;
 my $TH_CSS       = 'main.css';
+my $DEBUG = 0;
 #END OF SETTINGS
 
 my $cgi = CGI->new;
@@ -39,11 +36,15 @@ my $userid  =$session->param('alias');
 my $password=$session->param('passw');
 
 if(!$userid||!$dbname){
-   # print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid");
-  #  exit;
-  $userid ="admin";
-  $dbname = "data_admin_log.db";
-  $password = "admin";
+    if ($DEBUG){
+        $userid ="admin";
+        $dbname = "data_admin_log.db";
+        $password = "admin";
+    }
+    else{
+    print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid");
+    exit;
+    }
 }
 
 my $database = '../../dbLifeLog/' . $dbname;
@@ -103,6 +104,16 @@ my $gross   = big_money($income - $expense);
 $expense    = big_money(sprintf("%.2f",$expense));
 $income     = big_money(sprintf("%.2f",$income));
 
+
+#Under perlbrew, sometimes STDOUT is not piped back to our cgi,
+#utility inxi could be a perl written version on newer systems.
+#So I use the inter processing module here for inxi. -- @wbudic
+my  $HS = "";
+my @cmd = ("inxi", "-b", "-c0");
+run \@cmd, '>&', \$HS; #instead of -> system("inxi",'-b', '-c0');
+    $HS .= `uptime -p`;
+
+
 my $hardware_status = $HS;#`inxi -b -c0; uptime -p`;
 $hardware_status =~ s/\n/<br\/>/g;
 $hardware_status =~ s/Memory:/<b>Memory:/g;