add ExecuteCommand

This commit is contained in:
cangui 2024-12-13 19:25:02 +01:00
parent f49ca9ac46
commit 0adfd9e37a
2 changed files with 12 additions and 0 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -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)
}