From b44d288f423ede0fc7cdbf92d07a7772cd727de4 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Fri, 10 May 2024 06:56:54 +0200 Subject: [PATCH] Add logfile script --- save-log.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 save-log.sh diff --git a/save-log.sh b/save-log.sh new file mode 100755 index 0000000..4815a02 --- /dev/null +++ b/save-log.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# Purpose: Save a log file with RTW lines only. +# +# To make this file executable: +# +# $ chmod +x save-log.sh +# +# To execute this file: +# +# $ sudo ./save-log.sh +# +# or +# +# $ sudo sh save-log.sh + +SCRIPT_NAME="save-log.sh" + + +# check to ensure sudo was used to start the script +if [ "$(id -u)" -ne 0 ]; then + echo "You must run this script with superuser (root) privileges." + echo "Try: \"sudo ./${SCRIPT_NAME}\"" + exit 1 +fi + + +# deletes existing log +rm -f -- rtw.log + +dmesg | cut -d"]" -f2- | grep "RTW" >> rtw.log +RESULT=$? + + +if [ "$RESULT" != "0" ]; then + echo "An error occurred while running: ${SCRIPT_NAME}" + echo "Did you set a log level > 0 ?" + exit 1 +else + echo "rtw.log saved successfully." +fi