Fix script generate error and chmod