Используйте эту команду:
nano /root/.forward
Вставьте, отредактируйте или удалите электронные письма в этот текстовый файл, Ctrl + X , [Y], чтобы сохранить файл.
Спасибо slm за то, что указал мне правильное направление!
# Start the program with Power-On Reset
# Use tee to print output to terminal and pipe to grep
# grep returns 0 if the string is found
sudo./program -PO | tee /dev/tty | grep -q "Processor Reset."
# Store the grep exit code in a variable
result="$?"
# If result is 0, grep found the Processor Reset string
if [ "$result" == "0" ]; then
while : ; do
sudo./program -PR | tee /dev/tty | grep -q "Processor Reset."
result="$?"
# This loop will continue as long as the Processor Reset string is found
# once the program terminates
[ "$result" == "0" ] || break
done
fi
Что делать, если у вас есть такой сценарий оболочки:
$ cat top.bash
#!/bin/bash
echo "launched top.bash"
./fakeprog1.bash | grep -q "Processor Reset Received" && exec./fakeprog2.bash
Вы можете заменить ./fakeprog1.bash
на свой ./program -PO
и ./fakeprog2.bash
на свой ./program -PR
.
Когда я запускаю свою версию, она работает так:
$./top.bash
launched top.bash
launching /root/453742/fakeprog2.bash
fakeprog1.bash
отображает сообщение, но мы не можем его увидеть, потому что оно отфильтровывается с помощью grep
. Журналы могут быть направлены в файлы + этот скрипт через tee
, так что это не должно быть проблемой.