[LON-CAPA-cvs] cvs: loncom / loncron

raeburn raeburn at source.lon-capa.org
Wed May 6 10:31:59 EDT 2020


raeburn		Wed May  6 14:31:59 2020 EDT

  Modified files:              
    /loncom	loncron 
  Log:
  - Get hostname from Sys::Hostname::FQDN::fqdn.
  
  
Index: loncom/loncron
diff -u loncom/loncron:1.122 loncom/loncron:1.123
--- loncom/loncron:1.122	Wed May  6 13:34:22 2020
+++ loncom/loncron	Wed May  6 14:31:59 2020
@@ -2,7 +2,7 @@
 
 # Housekeeping program, started by cron, loncontrol and loncron.pl
 #
-# $Id: loncron,v 1.122 2020/05/06 13:34:22 raeburn Exp $
+# $Id: loncron,v 1.123 2020/05/06 14:31:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -46,6 +46,8 @@
 use Storable qw(thaw);
 use File::ReadBackwards;
 use File::Copy;
+use Sys::Hostname::FQDN();
+
 #globals
 use vars qw (%perlvar %simplestatus $errors $warnings $notices $totalcount);
 
@@ -1564,9 +1566,10 @@
     if ('{[[[[lonHostID]]]]}' eq $perlvar{'lonHostID'}) {
 	print("Unconfigured machine.\n");
 	my $emailto=$perlvar{'lonSysEMail'};
-	my $hostname=`/bin/hostname`;
-	chop $hostname;
-	$hostname=~s/[^\w\.]//g; # make sure is safe to pass through shell
+	my $hostname = Sys::Hostname::FQDN::fqdn();
+	$hostname=~s/\.+/./g;
+	$hostname=~s/\-+/-/g;
+	$hostname=~s/[^\w\.-]//g; # make sure is safe to pass through shell
 	my $subj="LON: Unconfigured machine $hostname";
 	system("echo 'Unconfigured machine $hostname.' |".
                " mail -s '$subj' $emailto > /dev/null");




More information about the LON-CAPA-cvs mailing list