Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Running a node.js REPL over `curl`
* Requires node v0.7.7 or greater.
* To connect: $ curl -sSNT. localhost:8000
var http = require('http')
, repl = require('repl')
, buf0 = new Buffer([0])
var server = http.createServer(function (req, res) {
res.setHeader('content-type', 'multipart/octet-stream')
res.write('Welcome to the Fun House\r\n')
prompt: 'curl repl> '
, input: req
, output: res
, terminal: false
, useColors: true
, useGlobal: false
// log
// hack to thread stdin and stdout
// simultaneously in curl's single thread
var iv = setInterval(function () {
}, 100)
res.connection.on('end', function () {
☮ ~ (master) ⚡ curl -sSNT. localhost:8000
Welcome to the Fun House
curl repl> process.platform
curl repl> process.arch
curl repl> process.cwd()
curl repl> path
{ resolve: [Function],
normalize: [Function],
join: [Function],
relative: [Function],
dirname: [Function],
basename: [Function],
extname: [Function],
_makeLong: [Function] }
curl repl> ^C
☮ ~ (master) ⚡

chemdemo commented Dec 3, 2012




mk-pmb commented Sep 18, 2017

The -sSNT curl options decode to: --silent --show-error --no-buffer --upload-file .. The dot as file name means to read file content from stdin in non-blocking mode, aka "show downloaded data while I'm still typing". I'd prefix the command with rlwrap to add line editing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment