I\'m having a little trouble figuring out how to get error output and store it in a variable or file in ksh. So in my script I have cp -p source.file destination
You can redirect the error output of the command like so:
cp -p source.file destination 2>> my_log.txt
It will append the error message to the my_log.txt file.
In case you want a variable you can redirect stderr to stdout and assign the command output to a variable:
my_error_var=$(cp -p source.file destination 2>&1)