add ExecuteCommand
This commit is contained in:
parent
f49ca9ac46
commit
0adfd9e37a
@ -255,3 +255,15 @@ func DownloadFile(sftpClient *sftp.Client, remoteFilePath, localFilePath string)
|
||||
fmt.Println("\nTéléchargement terminé:", localFilePath)
|
||||
return nil
|
||||
}
|
||||
func ExecuteCommand(command string,session *ssh.Session){
|
||||
// initialisation du buffer pour recupere les infos reçu de l' hôte
|
||||
var b bytes.Buffer
|
||||
session.Stdout = &b
|
||||
if err := session.Run(command); err != nil {
|
||||
fmt.Println(b)
|
||||
log.Fatal("Failed cmd: ", err)
|
||||
|
||||
}
|
||||
fmt.Println(b)
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user