script: add error check for robustness

Signed-off-by: Hiroshi Miura <miurahr@linux.com>