0

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?

user2058738
  • 349
  • 1
  • 6
  • 15

1 Answers1

0

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"
m47730
  • 2,061
  • 2
  • 24
  • 30
  • hmm. i was thinking of doing this approach `convert_status=`unoconv -f csv "$FILES"`` then if `[ $conver_status != ""] then echo "error_encountered"` .. what do you think? – user2058738 May 04 '18 at 06:31
  • @user2058738 i don't see difference between your codes: they do the same, so i'm expecting the same result – m47730 May 04 '18 at 07:52