This commit is contained in:
crusader 2017-12-14 15:38:50 +09:00
parent 6d2a0d64e0
commit cda77e4ad6
2 changed files with 8 additions and 4 deletions

View File

@ -32,12 +32,14 @@ func (c *SSHCrawler) InternalGet(config *configM.Config) (map[string]string, err
commands := ""
for i := 0; i < itemCount; i++ {
if "" != commands {
commands = fmt.Sprintf("%s;echo \"--%s\";", commands, boundary)
switch i {
case 0:
commands = config.Items[i].QueryInfo.Query
default:
commands = fmt.Sprintf("%s ; echo \"--%s\" ; %s ", commands, boundary, config.Items[i].QueryInfo.Query)
}
commands = fmt.Sprintf("%s;%s;", commands, config.Items[i].QueryInfo.Query)
}
commands = fmt.Sprintf("%s;echo \"--%s--\";", commands, boundary)
commands = fmt.Sprintf("%s ; echo \"--%s--\" ", commands, boundary)
buf, err := sshClient.RunCommand(commands)
if nil != err {

View File

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io/ioutil"
"log"
"time"
cuej "git.loafle.net/commons_go/util/encoding/json"
@ -68,6 +69,7 @@ func (cli *SSHClient) RunCommand(command string) ([]byte, error) {
var b bytes.Buffer
session.Stdout = &b
log.Printf("%s \n", command)
if err := session.Run(command); nil != err {
return nil, err
}