Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // include core lib
  2. const chalk = require('chalk')
  3. const { exec } = require('child_process')
  4.  
  5. // print "I'm process 1" by first process
  6. exec('ls -la', (error, stdout, stderr) => {
  7. if (error) {
  8. console.error(`exec error at process 1: ${error}`)
  9. return
  10. }
  11. console.log()
  12. console.log(chalk.bgGreen.black('Process 1 stdout'))
  13. console.log()
  14. console.log(`stdout: ${stdout}`)
  15. if (stderr) console.log(`stderr: ${stderr}`)
  16. })
  17.  
  18. // print "I'm process 2" by secound process
  19. exec('date', (error, stdout, stderr) => {
  20. if (error) {
  21. console.error(`exec error at process 2: ${error}`)
  22. return
  23. }
  24. console.log()
  25. console.log(chalk.bgGreen.black('Process 2 stdout'))
  26. console.log()
  27. console.log(`stdout: ${stdout}`)
  28. if (stderr) console.log(`stderr: ${stderr}`)
  29. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement