Skip to content

Commit

Permalink
fix(v1.0): fix replace
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu committed Mar 24, 2020
1 parent bfb1f5a commit 6eac7d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/sshutil/ssh.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package sshutil

import "github.com/wonderivan/logger"
import (
"github.com/wonderivan/logger"
"strings"
)

//Cmd is
//Cmd is in host exec cmd
func (ss *SSH) Cmd(host string, cmd string) []byte {
logger.Info("[%s]exec cmd is : %s", host, cmd)
session, err := ss.Connect(host)
Expand All @@ -29,9 +32,12 @@ func (ss *SSH) Cmd(host string, cmd string) []byte {
return b
}

func (ss *SSH) CmdToString(host, cmd string) string {
//CmdToString is in host exec cmd and replace to spilt str
func (ss *SSH) CmdToString(host, cmd, spilt string) string {
data := ss.Cmd(host, cmd)
if data != nil {
str := string(data)
str = strings.ReplaceAll(str, "\r\n", spilt)
return string(data)
}
return ""
Expand Down

0 comments on commit 6eac7d9

Please sign in to comment.