From 76c35c19836439ecec94ece0c7b27a877e8b07b9 Mon Sep 17 00:00:00 2001 From: "Ramón M. Gómez" Date: Thu, 25 Jul 2019 13:25:55 +0200 Subject: #920: Truncate a long serial number. --- client/engine/Inventory.lib | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client/engine/Inventory.lib b/client/engine/Inventory.lib index 1dd7173c..f3a779d7 100755 --- a/client/engine/Inventory.lib +++ b/client/engine/Inventory.lib @@ -90,7 +90,6 @@ esac } - #/** # ogGetSerialNumber #@brief Obtiene el nº de serie del cliente. @@ -98,17 +97,22 @@ esac #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2015-06-08 #*/ ## - function ogGetSerialNumber () { +# Variables locales. +local SERIALNO # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME" + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 123456" return fi -# Obtener nº de serie (ignorar los no especificados) -dmidecode -s system-serial-number | egrep -vi "(^[ 0]+$|not specified|to be filled|invalid entry)" +# Obtener nº de serie (ignorar los no especificados). +SERIALNO=$(dmidecode -s system-serial-number | egrep -vi "(^[ 0]+$|not specified|to be filled|invalid entry|default string)") +# Truncar cadena si >25 caracteres. +[ ${#SERIALNO} -gt 25 ] && SERIALNO="${SERIALNO:0:22}..." +[ -n "$SERIALNO" ] && echo "$SERIALNO" +return 0 } -- cgit v1.2.3-18-g5258