From 81670219c530f5455a4c1982a5647fa158bcce3e Mon Sep 17 00:00:00 2001 From: kapeller Date: Wed, 21 May 2014 11:17:31 +0000 Subject: [PATCH] fixed \r\n issue --- shellbox_from_db | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/shellbox_from_db b/shellbox_from_db index e7296fa..32608f4 100755 --- a/shellbox_from_db +++ b/shellbox_from_db @@ -5,7 +5,7 @@ # a configuration file for the shellbox service. # Create/update /etc/shellbox.d/.conf files # -# $Id: shellbox_from_db,v 1.1 2014/05/21 08:33:20 kapeller Exp $ +# $Id: shellbox_from_db,v 1.2 2014/05/21 11:17:31 kapeller Exp $ # $Source: /cvs/G/EPICS/App/scripts/shellbox_from_db,v $ ############################################################################### # @@ -48,7 +48,7 @@ lock if (wget -qO $tmpfile https://inventory.psi.ch/soap/softioc_info.aspx?host=$hostname); then mkdir -p $SHELLBOX_DIR rm $SHELLBOX_DIR/.[0-9]*.conf - while IFS=$'\n' read line; do + cat $tmpfile | tr -d '\r' | while IFS=$'\n' read line; do if [ -n "$line" ]; then port=$(echo $line | cut -d ' ' -f 1) user=$(echo $line | cut -d ' ' -f 2) @@ -59,16 +59,18 @@ if (wget -qO $tmpfile https://inventory.psi.ch/soap/softioc_info.aspx?host=$host new_file="$SHELLBOX_DIR/.${port}.conf" old_file="$SHELLBOX_DIR/${port}.conf" echo "#" > $new_file - echo "# This file is generated by $progname." >> $new_file + echo "# This file has been generated by $progname." >> $new_file echo "# Manual changes will get lost!" >> $new_file echo "#" >> $new_file echo "$line" >> $new_file + echo "### EOF" >> $new_file if (! cmp -s $new_file $old_file); then + subject="SoftIOC #$port on $hostname has changed" + diff -u $new_file $old_file | mail -s "$subject" $email cp $new_file $old_file - mail -s "$hostname - $progname - $old_file changed" $email < $old_file fi fi - done < $tmpfile + done fi rm $tmpfile