mirror of
https://github.com/shanghai-edu/multissh.git
synced 2025-12-16 05:17:52 +00:00
version 0.2.2
add filelocate
This commit is contained in:
parent
360caeb82e
commit
82bd4c6577
3 changed files with 14 additions and 10 deletions
4
g/cfg.go
4
g/cfg.go
|
|
@ -84,8 +84,8 @@ func GetJsonFile(filePath string) ([]SSHHost, error) {
|
|||
result = m.SshHosts
|
||||
return result, nil
|
||||
}
|
||||
func WriteIntoTxt(sshResult SSHResult) error {
|
||||
outputFile, outputError := os.OpenFile(sshResult.Host+".txt", os.O_WRONLY|os.O_CREATE, 0666)
|
||||
func WriteIntoTxt(sshResult SSHResult, locate string) error {
|
||||
outputFile, outputError := os.OpenFile(locate+sshResult.Host+".txt", os.O_WRONLY|os.O_CREATE, 0666)
|
||||
if outputError != nil {
|
||||
return outputError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package g
|
|||
// 0.1.2 fix ssh error on h3c switch
|
||||
// 0.2
|
||||
// 0.2.1
|
||||
// add write locate file
|
||||
const (
|
||||
VERSION = "0.2.1"
|
||||
VERSION = "0.2.2"
|
||||
)
|
||||
|
|
|
|||
17
main.go
17
main.go
|
|
@ -29,6 +29,7 @@ func main() {
|
|||
cfgFile := flag.String("c", "", "cfg File Path")
|
||||
jsonMode := flag.Bool("j", false, "print output in json format")
|
||||
outTxt := flag.Bool("outTxt", false, "write result into txt")
|
||||
fileLocate := flag.String("f", "", "write file locate")
|
||||
linuxMode := flag.Bool("l", false, "In linux mode,multi command combine with && ,such as date&&cd /opt&&ls")
|
||||
timeLimit := flag.Int("t", 30, "max timeout")
|
||||
numLimit := flag.Int("n", 20, "max execute number")
|
||||
|
|
@ -143,12 +144,13 @@ func main() {
|
|||
//gu
|
||||
if *outTxt {
|
||||
for _, sshResult := range sshResults {
|
||||
err = g.WriteIntoTxt(sshResult)
|
||||
err = g.WriteIntoTxt(sshResult, *fileLocate)
|
||||
if err != nil {
|
||||
log.Println("write into txt error: ", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if *jsonMode {
|
||||
jsonResult, err := json.Marshal(sshResults)
|
||||
|
|
@ -156,11 +158,12 @@ func main() {
|
|||
log.Println("json Marshal error: ", err)
|
||||
}
|
||||
fmt.Println(string(jsonResult))
|
||||
} else {
|
||||
for _, sshResult := range sshResults {
|
||||
fmt.Println("host: ", sshResult.Host)
|
||||
fmt.Println("========= Result =========")
|
||||
fmt.Println(sshResult.Result)
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, sshResult := range sshResults {
|
||||
fmt.Println("host: ", sshResult.Host)
|
||||
fmt.Println("========= Result =========")
|
||||
fmt.Println(sshResult.Result)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue