I was tasked to create an automated server hardening script and one thing that they need is a report of all the output of each command executed. I want to store the error message inside a string and append it in a text file.
Let's say I ran this command:
/sbin/modprobe -n -v hfsplus
The output of running this in my machine would be:
FATAL: Module hfsplus not found
How can I store that error message inside a string? Any help would be greatly appreciated. Thanks!