error handling in unoconv

220 Views Asked by At

I have a script that automatically converts excel file from xls to csv using unoconv. From time to time I'm getting this error.

line 174: 21023 Segmentation fault  unoconv -f csv "$FILES"

I want to be able to handle any error that occurs upon conversion. I've tried adding this to the script.

unoconv -f csv "$FILES"
if [ $? -ne 0 ]; then
    echo "error encountered when converting from xls to csv"
else
    echo "Successfully converted to csv"
fi

My problem is that. Even if I encounter that error. The error message is not being reflected. Is there anything I'm doing wrong?

1

There are 1 best solutions below

2
On

try something like:

unoconv -f csv "$FILES" 2>&1 | grep -i "Segmentation fault" &>/dev/null \
&& echo "error encountered when converting from xls to csv" \
|| echo "Successfully converted to csv"