Finally I fixed my problem. I am posting here the solution if anybody else gets stuck at the same point as I did and desperately reach here.
confirm.php file, I included another file which contained functions as well as a Class object. The command line cannot execute methods in the Class object unless it is called from the original file with
echo or explicitly passing the class to the command like
php -r 'include "Class_file.php"; echo MyClass::method(); '. Since my
confirm.php file depended on this Class for further processing, it failed here. This post helped me to figure it out: