执行脚本命令

时间:2022-03-17 09:10:25
package main

import (
    "os/exec"
    "fmt"
)

func main()  {
    var(
        cmd *exec.Cmd
        output []byte
        err error
    )

    cmd = exec.Command("D:\\phpStudy\\PHPTutorial\\php\\php-5.6.27-nts\\php.exe","-m")
    if output,err = cmd.CombinedOutput();err !=nil{
        fmt.Println(err)
        return
    }
    fmt.Println(string(output))
}
执行脚本命令执行脚本命令
GOROOT=D:\go #gosetup
GOPATH=D:\gospace;C:\Users\Administrator\go #gosetup
D:\go\bin\go.exe build -i -o C:\Users\Administrator\AppData\Local\Temp\___go_build_main_go__4_.exe D:/gospace/src/gocode/test/main.go #gosetup
D:\soft\GoLand\bin\runnerw.exe C:\Users\Administrator\AppData\Local\Temp\___go_build_main_go__4_.exe #gosetup
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mcrypt
mhash
mongodb
mysql
mysqli
mysqlnd
odbc
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend Guard Loader
zip
zlib

[Zend Modules]
Zend Guard Loader



Process finished with exit code 0
View Code