I have something like below in my mongo js file
db.eval(function(){
   db.user.find( { email : {$exists : false}} ).forEach(
     function(found){
            id = found._id; 
            print(id);  // this will print to mongo logs
print() will print to mongodb logs but I want to send these ids found to an output.txt file in some other location . Because I need to email this file for further processing. Is it possible ? Thanks..