fix: exec.Command cannot output
This commit is contained in:
parent
0a5f6f69c6
commit
3a38a1a146
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -119,7 +120,9 @@ func BeanReportAllPrices(ledgerConfig *Config) []CommodityPrice {
|
||||||
command = fmt.Sprintf(`bean-query %s "SELECT date, 'price', currency, price FROM account ~ 'Assets' WHERE price is not NULL"`, beanFilePath)
|
command = fmt.Sprintf(`bean-query %s "SELECT date, 'price', currency, price FROM account ~ 'Assets' WHERE price is not NULL"`, beanFilePath)
|
||||||
}
|
}
|
||||||
LogInfo(ledgerConfig.Mail, command)
|
LogInfo(ledgerConfig.Mail, command)
|
||||||
cmd := exec.Command(command)
|
re := regexp.MustCompile(`"([^"]*)"|(\S+)`)
|
||||||
|
cmds := re.FindAllString(command, -1)
|
||||||
|
cmd := exec.Command(cmds[0], cmds[1:]...)
|
||||||
output, _ := cmd.Output()
|
output, _ := cmd.Output()
|
||||||
outputStr := string(output)
|
outputStr := string(output)
|
||||||
lines := strings.Split(outputStr, "\n")
|
lines := strings.Split(outputStr, "\n")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue