fixed \r\n issue

This commit is contained in:
kapeller
2014-05-21 11:17:31 +00:00
parent 3339b96e84
commit 81670219c5
+7 -5
View File
@@ -5,7 +5,7 @@
# a configuration file for the shellbox service.
# Create/update /etc/shellbox.d/<port>.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