@Anurag Mishra
Can you please share the complete error that you are getting? Also little detail about what your script is doing?
It might be the HDFS directory where the user "yarn" is trying to write and does not have write permission. If that is the case then you might want to give write permission to the "yarn" user to that HDFS directory.
# su - hdfs -c "hdfs dfs -chmod 777 /PATH/WHERE/YARN/USER/IS/WRITING
(OR)
# su - hdfs -c "hdfs dfs -chown -R yarn:hadoop /PATH/WHERE/YARN/USER/IS/WRITING
.