Thank you Jon for suggesting this solution. I tried by breaking script_name.sh script into multiple scripts and all individual scripts running properly, it is not throwing module failure error now. And when I run a script_name.sh again ,it is throwing module failure error. The conclusion is there is no issue with script or module. I just want to tell one thing that I observed .
We are using amazon ec2 instance(ubuntu) and from 2 days it is working slowly. And when I deploy script to server, it is taking 10-12 minutes to execute script (before it was taking 2-3 minutes)and at one point process get halt and jenkins server through error. I don't understand why it is happening, but I applied your solutions and it is working.
Thank you Jon
Regards,
Jayashri