[LON-CAPA-cvs] cvs: loncom /misc checkforupdates.pl

raeburn raeburn at source.lon-capa.org
Thu Feb 14 09:18:27 EST 2013


raeburn		Thu Feb 14 14:18:27 2013 EDT

  Modified files:              
    /loncom/misc	checkforupdates.pl 
  Log:
  - Output written directly to lon-status/checkLCupdates.txt instead of an
    intermediate temporary file in /tmp. 
  
  
Index: loncom/misc/checkforupdates.pl
diff -u loncom/misc/checkforupdates.pl:1.1 loncom/misc/checkforupdates.pl:1.2
--- loncom/misc/checkforupdates.pl:1.1	Sat Feb  2 00:22:39 2013
+++ loncom/misc/checkforupdates.pl	Thu Feb 14 14:18:27 2013
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # The LearningOnline Network
 #
-# $Id: checkforupdates.pl,v 1.1 2013/02/02 00:22:39 raeburn Exp $
+# $Id: checkforupdates.pl,v 1.2 2013/02/14 14:18:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -61,7 +61,6 @@
 use LONCAPA::Checksumming;
 use Apache::loncommon();
 
-my $tmpfile = '/tmp/checkLONCAPA.'.$$;
 my $perlvar= LONCAPA::Configuration::read_conf('loncapa.conf');
 
 my ($londaemons,$lonlib,$lonincludes,$lontabdir,$lonhost,$defdom,$origmail,
@@ -164,32 +163,31 @@
                                   $production.'-'.$proddate,
                                   "\n http://install.loncapa.org/\n");
     }
-    if (open(my $tmpfh,">$tmpfile")) {
-        print $tmpfh 
+}
+
+if ($docroot ne '') {
+    if (open(my $fh,">$docroot/lon-status/checkLCupdates.txt")) {
+        print $fh
              &Apache::lonlocal::mt('Update check result -- [_1]',
                                    &Apache::lonlocal::locallocaltime(time)).
              "\n\n".
              $message;
-        close($tmpfh);
-    }
-}
-
-if ($docroot ne '') {
-    system("cat $tmpfile > $docroot/lon-status/checkLCupdates.txt");
-    if ($< == 0) {
+        close($fh);
         system("chown www:www $docroot/lon-status/checkLCupdates.txt");
-    }
-    chmod(0600,"$docroot/lon-status/checkLCupdates.txt");
-}
+        chmod(0600,"$docroot/lon-status/checkLCupdates.txt");
 
-# Determine who receives the e-mail
-my $emailto =
-    &Apache::loncommon::build_recipient_list(undef,'updatesmail',
-                                             $defdom,$origmail);
-if ($emailto) {
-    if ($send) {
-        my $subj = "LON-CAPA module check -- $lonhost"; 
-        system(qq{mail -s '$subj' "$emailto" < $tmpfile});
+        if ($send) {
+            # Determine who receives the e-mail
+            my $emailto =
+                &Apache::loncommon::build_recipient_list(undef,'updatesmail',
+                                                         $defdom,$origmail);
+            if ($emailto) {
+                my $subj = "LON-CAPA module check -- $lonhost";
+                if (-e "$docroot/lon-status/checkLCupdates.txt") {
+                    system(qq{mail -s '$subj' "$emailto" < $docroot/lon-status/checkLCupdates.txt});
+                }
+            }
+        }
     }
 }
 




More information about the LON-CAPA-cvs mailing list