Skip to content

Instantly share code, notes, and snippets.

@Quaggie
Created October 30, 2016 17:52
Show Gist options
  • Save Quaggie/be4f1c95b763b738e7e3597290b082d6 to your computer and use it in GitHub Desktop.
Save Quaggie/be4f1c95b763b738e7e3597290b082d6 to your computer and use it in GitHub Desktop.
const spawn = require('child_process').spawn; // child_process spawn function
const app = require('express')(); // new express http server
app.use('/', (req, res) => {
const ls = spawn('ls', ['-lh', '/usr']); // here would be the mysqldump command
ls.stdout.pipe(res);
}); // piping the stdout (the output from the mysqldump command, in this case the ls command) to the response object
// using fs
const fs = require('fs');
app.use('/old/bump', (req, res) => {
const fileStream = fs.createReadStream('path_to_dump.sql');
fileStream.pipe(res);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment