[vhffs-dev] [2033] removed all remaining system() from everywhere

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2033
Author:   gradator
Date:     2012-02-20 00:43:49 +0100 (Mon, 20 Feb 2012)
Log Message:
-----------
removed all remaining system() from everywhere

Modified Paths:
--------------
    trunk/vhffs-robots/src/listengine_publicarchives.pl
    trunk/vhffs-robots/src/repository_stats.pl
    trunk/vhffs-robots/src/web_stats.pl

Modified: trunk/vhffs-robots/src/listengine_publicarchives.pl
===================================================================
--- trunk/vhffs-robots/src/listengine_publicarchives.pl	2012-02-19 23:20:37 UTC (rev 2032)
+++ trunk/vhffs-robots/src/listengine_publicarchives.pl	2012-02-19 23:43:49 UTC (rev 2033)
@@ -107,7 +107,7 @@
 			mkdir($outputmonthdir, 0755) or die("Unable to create $outputmonthdir directory: $!\n") unless(-d $outputmonthdir);
 
 			# TODO: as we need to parse folder recursively, remove the glob
-			my $childpid = open( my $output, 'mhonarc', '-add', '-quiet', '-rc', $configmhonarc, '-definevar', 'MAIN-TITLE='.$list->get_domain.'/'.$list->get_localpart, '-outdir', $outputmonthdir, glob($monthpath.'/*/*') );
+			my $childpid = open( my $output, '-|', 'mhonarc', '-add', '-quiet', '-rc', $configmhonarc, '-definevar', 'MAIN-TITLE='.$list->get_domain.'/'.$list->get_localpart, '-outdir', $outputmonthdir, glob($monthpath.'/*/*') );
 			if($childpid) {
 				# read process output and print
 				while(<$output>) { print $_; }

Modified: trunk/vhffs-robots/src/repository_stats.pl
===================================================================
--- trunk/vhffs-robots/src/repository_stats.pl	2012-02-19 23:20:37 UTC (rev 2032)
+++ trunk/vhffs-robots/src/repository_stats.pl	2012-02-19 23:43:49 UTC (rev 2033)
@@ -29,6 +29,7 @@
 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 # POSSIBILITY OF SUCH DAMAGE.
 
+#TODO: Rework that...
 
 #Your logs must be in format : "%V %h %l %u %t \"%r\" %>s %b"
 #So, add in your httpd.conf following lines :
@@ -114,8 +115,14 @@
 
 # Restart locally or wait 180 seconds to be sure all apache are restarted (welcome to the land of pigs)
 if( $log_apachelocal )  {
-	my $cmd = $log_apachectl." graceful";
-	system ( $cmd );
+	my $childpid = open( my $output, '-|', $log_apachectl, 'graceful' );
+	if($childpid) {
+		# read process output and discard
+		while(<$output>) {}
+
+		# wait for the child to finish
+		waitpid( $childpid, 0 );
+	}
 } else {
 	sleep ( 180 );
 }
@@ -125,9 +132,17 @@
 unlink $log_incoming_root."/rejectlog" if( -f $log_incoming_root."/rejectlog" );
 
 # Merge all logs
-my $cmd = "mergelog ".$log_incoming_root."/*/http.log.0 ".$log_incoming_root."/*/ftp.log.0 > ".$log_incoming_root."/mergedlog";
-system ( $cmd );
+open( my $mergedoutput, '>', $log_incoming_root.'/mergedlog' );
+my $childpid = open( my $output, '-|', 'mergelog', glob($log_incoming_root.'/*/http.log.0'), glob($log_incoming_root.'/*/ftp.log.0') );
+if($childpid) {
+	# read process output and print to destination
+	while(<$output>) { print $mergedoutput $_; }
 
+	# wait for the child to finish
+	waitpid( $childpid, 0 );
+}
+close( $mergedoutput );
+
 # Parse http logs
 my $prev = "";
 my $ddir = $vhffs->get_config->get_datadir."/repository/";
@@ -223,9 +238,15 @@
 	close( AWFILEIN );
 
 	# Generate statistics
-	$cmd = $log_awstats." -config=".$reponame." -update 2>/dev/null 1>/dev/null";
-	system( $cmd );
+	my $childpid = open( my $output, '-|', $log_awstats, '-config='.$reponame, '-update' );
+	if($childpid) {
+		# read process output and discard
+		while(<$output>) {}
 
+		# wait for the child to finish
+		waitpid( $childpid, 0 );
+	}
+
 	# Rotate logs for this website
 	Vhffs::Robots::rotate_log( $logpath , $log_parsed_rotation , $log_parsed_compress );
 }

Modified: trunk/vhffs-robots/src/web_stats.pl
===================================================================
--- trunk/vhffs-robots/src/web_stats.pl	2012-02-19 23:20:37 UTC (rev 2032)
+++ trunk/vhffs-robots/src/web_stats.pl	2012-02-19 23:43:49 UTC (rev 2033)
@@ -29,6 +29,7 @@
 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 # POSSIBILITY OF SUCH DAMAGE.
 
+#TODO: Rework that...
 
 #Your logs must be in format : "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""  
 #So, add in your httpd.conf following lines :
@@ -115,8 +116,14 @@
 
 # Restart locally or wait 180 seconds to be sure all apache are restarted (welcome to the land of pigs)
 if( $log_apachelocal )  {
-	my $cmd = $log_apachectl." graceful";
-	system ( $cmd );
+	my $childpid = open( my $output, '-|', $log_apachectl, 'graceful' );
+	if($childpid) {
+		# read process output and discard
+		while(<$output>) {}
+
+		# wait for the child to finish
+		waitpid( $childpid, 0 );
+	}
 } else {
 	sleep ( 180 );
 }
@@ -126,9 +133,16 @@
 unlink $log_incoming_root."/rejectlog" if( -f $log_incoming_root."/rejectlog" );
 
 # Merge all logs
-my $cmd = "mergelog ".$log_incoming_root."/*/vhffs.log.0 > ".$log_incoming_root."/mergedlog";
-system ( $cmd );
+open( my $mergedoutput, '>', $log_incoming_root.'/mergedlog' );
+my $childpid = open( my $output, '-|', 'mergelog', glob($log_incoming_root.'/*/vhffs.log.0') );
+if($childpid) {
+	# read process output and print to destination
+	while(<$output>) { print $mergedoutput $_; }
 
+	# wait for the child to finish
+	waitpid( $childpid, 0 );
+}
+close( $mergedoutput );
 
 # Parse http logs
 my $prev = "";
@@ -213,9 +227,15 @@
 	close( AWFILEIN );
 
 	# Generate statistics
-	$cmd = $log_awstats." -config=".$svname." -update 2>/dev/null 1>/dev/null";
-	system( $cmd );
+	my $childpid = open( my $output, '-|', $log_awstats, '-config='.$svname, '-update' );
+	if($childpid) {
+		# read process output and discard
+		while(<$output>) {}
 
+		# wait for the child to finish
+		waitpid( $childpid, 0 );
+	}
+
 	# Rotate logs for this website
 	Vhffs::Robots::rotate_log( $logpath , $log_parsed_rotation , $log_parsed_compress );
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/