If it is a server, then yes, you will have to make-do with the other solutions (Javascript). I'm currently working on getting nodejs to do the same as WWW::Mechanize::Firefox does, except without the need for a display, but that is still very much a work in progress, so I recommend you look at the other methods.

Alternatively, you could write a small Javascript wrapper for your sso.gen script and call it via node sso.gen-wrapper.js $ARG1 $ARG2 via backticks.