exec (sync)
Node.js
const { execSync } = require('child_process')
const output = execSync(`echo 'hello world'`)
console.log(output.toString())
Output
hello world
Go
package main
import (
"fmt"
"os/exec"
)
func main() {
output, err := exec.Command("echo", "hello world").Output()
if err != nil {
panic(err)
}
fmt.Println(string(output))
}
Output
hello world
当前内容版权归 miguelmota 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 miguelmota .