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!
And then displaying it:
But it still doesn't capture the error message inside the string.
– Miguel Roque May 29 '14 at 07:42