javascript - Get my OS from the node.js shell -
this question has answer here:
how can access os node shell?
context: i'm writing script in node want open file default program, , commands doing vary across os.
i've tried standard javascript ways of getting os, haven't worked (for obvious reasons, there no navigator
in node).
is possible without installing nonstandard modules?
warning: might outdated
there no navigator
object in node.js, because not run in browser. runs in system. "equivalent" navigator process
. object holds many information, e.g.
process.platform // linux
if want run web browser, have execute it..
var sys = require('sys') // open google in default browser // (at least in ubuntu-like systems) sys.exec('x-www-browser google.com')
this might not work in newer node.js versions (i have 2.x), might have use
var child_process = require('child_process') child_process.exec('x-www-browser google.com')
i guess there no simple way how multiplatform "run" file "default app", have find out how in each os / desktop environment, , after os detection.
Comments
Post a Comment