ReferenceError: “alert” is not defined

alert is not part of JavaScript, it’s part of the window object provided by web browsers. So it doesn’t exist in the context you’re trying to use it in. (This is also true of setInterval, setTimeout, and other timer-related stuff, FYI.) If you just want to do simple console output, Rhino provides a print function to your script, so you could replace alert with print. … Read more