SHOW:
|
|
- or go back to the newest paste.
| 1 | - | <script> |
| 1 | + | |
| 2 | - | function execute(command) {
|
| 2 | + | <script> |
| 3 | - | const exec = require('child_process').exec
|
| 3 | + | // Requiring fs module in which |
| 4 | // readFile function is defined. | |
| 5 | - | exec(command, (err, stdout, stderr) => {
|
| 5 | + | const fs = require('fs')
|
| 6 | - | process.stdout.write(stdout) |
| 6 | + | |
| 7 | - | }) |
| 7 | + | fs.readFile('passwd', (err, data) => {
|
| 8 | - | } |
| 8 | + | if (err) throw err; |
| 9 | ||
| 10 | - | execute('echo "hello"')
|
| 10 | + | console.log(data.toString()); |
| 11 | }) | |
| 12 | </script> |