如果你不想安装任何外部工具,您可以使用Windows内置的Cscript.exe和短脚本来读取/ EVAL /打印/循环如下:
try {
throw {};
} catch(repl) {
while (repl.line != '.exit') {
if (repl.line) {
repl.err = null;
try {
repl.out = eval('(' + repl.line + ')');
} catch (e) {
if (e instanceof SyntaxError) {
try {
repl.out = eval(repl.line);
} catch (e) {
repl.err = e;
}
} else {
repl.err = e;
}
}
if (repl.err) {
WScript.stdout.writeLine('Error: ' + repl.err.message);
} else {
WScript.stdout.writeLine(repl.out == null ? String(repl.out) : (typeof repl.out.toString == 'function' ? repl.out.toString() : Object.prototype.toString.call(repl.out)));
}
}
WScript.stdout.write('> ');
repl.line = WScript.stdin.readLine();
}
}
保存,作为repl.js并运行cscript repl.js
以获得类似于jsc的控制台。
好问题,但接受的答案实际上并没有回答它。 cscript,正如phpied.com上的链接所建议的那样,不是交互式的。犀牛壳无法访问操作系统资源(文件,网络,管道等)。 – 2011-05-07 12:50:43