sajad torkamani
import { spawn } from 'child_process'

const whoami = spawn('whoami')

whoami.on('data', (data) => {
  console.log(`stdout: ${data}`)
})

whoami.on('error', (error) => {
  console.log(`stderr: ${error.message}`)
})

whoami.on('close', (code) => {
  console.log(`child process exited with code ${code}`)
})

Sources

Leave a comment

Your email address will not be published. Required fields are marked *