exec (async)
Node.js
const { exec } = require('child_process')
exec(`echo 'hello world'`, (error, stdout, stderr) => {
if (error) {
console.error(err)
}
if (stderr) {
console.error(stderr)
}
if (stdout) {
console.log(stdout)
}
})
Output
hello world
Go
package main
import (
"os"
"os/exec"
)
func main() {
cmd := exec.Command("echo", "hello world")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}
Output
hello world
当前内容版权归 miguelmota 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 miguelmota .