草庐IT

execute_command_line

全部标签

go - 捕获 exec.Command 的缓冲标准输出输出

我正在尝试捕捉外部程序的输出。示例:#include#include#includeintmain(){inti=0;while(i这是我的main.go:packagemainimport("bufio""io""log""os/exec")funcreecho(closerio.ReadCloser){reader:=bufio.NewReader(closer)for{s,e:=reader.ReadString('\n')ife!=nil{log.Println(e)break}log.Println(s)}}funcmain(){cmd:=exec.Command("./in

google-app-engine - 戈朗 : Audio to FLAC conversion without running a executable

我正在尝试制作一个从存储中获取文件并将任意音频文件转换为FLAC的GoogleAppEngine。但是,AppEngine不允许运行可执行文件。我当前的代码看起来像这样:cmd:=exec.CommandContext(ctx,`./ffmpeg`,`-i`,`pipe:0`,`pipe:1`,`-ac`,`1`,`-c:a`,`flac`,`-f`,`flac`)cmd.Stdin=rccmd.Stdout=wcvarerrOutputbytes.Buffercmd.Stderr=&errOutputerr=cmd.Run()fmt.Printf("Runningffmpeg:%v.

macos - 在 golang 中使用 exec.Command,如何打开一个新终端并执行命令?

当我在终端中直接输入命令时,我能够得到以下命令来打开一个新终端并执行命令,但是当我在go中使用exec.Commmand函数时,我无法让它工作。osascript-e'tellapplication"Terminal"todoscript"echohello"'我认为问题出在双引号和单引号中,但我不确定是什么导致了错误。c:=exec.Command("osascript","-e","'tell","application",`"Terminal"`,"to","do","script",`"echo`,`hello"'`)iferr:=c.Run();err!=nil{fmt.Pr

editor - SciTE 中的多行 command.go

短片这涉及SciTE和Windows(特别是Windows7)中的go语言。这是我第一次使用SciTE,所以如果有其他方法可以实现我的目标,那也很好。目标:一键编译、链接和执行新创建的二进制文件。龙我想在SciTE的“go”命令下设置编译/链接/执行。这可能有点令人困惑,因为它也适用于golanguage。.这是我目前所拥有的:command.compile.*.go=8g$(FileNameExt)command.build.*.go=8l-o$(FileName).exe$(FileName).8command.go.*.go=$(FileName).exe我想要的是:comman

stream - Golang - 函数 "Execute"在哪里写入流?

我是Go的初学者,我不明白在函数Execute的流中写入数据“home.html”的调用在哪里。http.ResponseWriter是作者,很清楚但在函数Execute中我看不到任何类似write..fmt.Fprint..我只看到Execute的递归http://golang.org/src/pkg/html/template/template.go?s=1245:1315#L40//myFunctionfunchomeHandler(chttp.ResponseWriter,req*http.Request){varhomeTempl=template.Must(template

windows - 转到异常 "signal arrived during cgo execution"

在什么情况下Go在调用dll时会出现“signalarrivedduringcgoexecution”之类的panic?要调用的代码是——基于go分发的src中的zsyscall_windows.go中的示例:var(//entrynamesfoundusingdumpbin/exportsdllSweph=syscall.NewLazyDLL("swedll32.dll")_swe_jdut1_to_utc=dllSweph.NewProc("_swe_jdut1_to_utc@36")_swe_julday=dllSweph.NewProc("_swe_julday@24"))fu

go - 无法使用 Docker 容器自动运行简单的 Go Web 服务器(func (*Template) Execute)

所以我试图在CoreOS上的docker容器中自动运行一个简单的“helloworld”网络服务器。但是当应用程序尝试执行HTML模板时出现错误。这是有问题的代码:funcGateHandler(whttp.ResponseWriter,r*http.Request){fmt.Println("EnteredtheGateHandler.")t,_:=template.ParseFiles("templates/helloworld.html")fmt.Println("PassedtheParseFiles.")err:=t.Execute(w,nil)fmt.Println("Pa

go - 如何将 exec.Command 的输出通过管道传输到 Golang 中的另一个命令

我有八个MicrosoftAccess数据库,每个数据库都有大约215个表,我需要将这些数据库传输到postgresql,所以我使用mdb-tools并导出方案,这只是一步;但是当涉及到直接将表数据导出到postgres时在postgresql中,我必须为每个表编写此命令:mdb-export-Ipostgres-q\'myaccessdatabase.mdbtable-name|psql-dmypsqldatabase-Upostgres-w-hlocalhost所以我一直在尝试编写一个go命令程序来做如下:1.首先执行命令列出表名。这将是下一个命令的参数。2.然后开始forrang

go - go 'Template.Execute'如何读取其匿名结构的参数字段?

在使用Go编码时,使用html.template包,调用template.Execute。我有一个问题,它如何读取其参数的匿名结构字段。看了源码,没看懂。我不知道。/usr/local/go/src/html/template/tempalte.goL.78typeTemplatestruct{...text*template.Template...}//escapeescapesallassociatedtemplates.func(t*Template)escape()error{t.nameSpace.mu.Lock()defert.nameSpace.mu.Unlock()if

python - 尝试使用 exec.Command(

funcexecPython(fPath,colName,srvstring)(){fmt.Println("InsideexecPython")cmd:="pythonrfsvmchurn.py"arg0:="-fp"+fPatharg1:="-srv"+srvarg2:="-col"+colNameiferr:=exec.Command(cmd,arg0,arg1,arg2).Run();err!=nil{fmt.Println("PythonExecutionError:",err)}出现错误Python执行错误:exec:“pythonrfsvmchurn.py”:在$PATH