为什么我从golang错误运行python脚本
错误:没有此类文件错误:/root/hi.py>/root/1.log为什么我从golang错误运行python脚本,go,exec,Go,Exec,错误:没有此类文件错误:/root/hi.py>/root/1.log import ( "fmt" "os/exec" "bytes" ) func main() { cmd :="/root/hi.py > /root/1.log" out,err:= exec.Command("python","-c",cmd).Output() fmt.Printf("Out: %s ", string(out)) fmt.Printf(
import (
"fmt"
"os/exec"
"bytes"
)
func main() {
cmd :="/root/hi.py > /root/1.log"
out,err:= exec.Command("python","-c",cmd).Output()
fmt.Printf("Out: %s ", string(out))
fmt.Printf("Err: %s ", err.Error())
}
文件
hi.py
在哪里?尝试按参数拆分它,它似乎在尝试filename/root/hi.py>/root/1。log
清楚地指示文件名及其路径和内容、您放置的命令和命令的输出,以便人们更容易识别问题。两个主要错误:您正在执行shell脚本(带有
的重定向由shell执行)。每个参数必须是它自己的字符串。
//hi.py
#! /usr/bin/python
print('hello world')