From 0adfd9e37a8755d76fdcedeef17651ed42db5e43 Mon Sep 17 00:00:00 2001 From: cangui Date: Fri, 13 Dec 2024 19:25:02 +0100 Subject: [PATCH] add ExecuteCommand --- .DS_Store | Bin 6148 -> 6148 bytes simply-ssh/main.go | 12 ++++++++++++ 2 files changed, 12 insertions(+) diff --git a/.DS_Store b/.DS_Store index 915c48633de2130e008d048a99d9b6b743b03897..f3437183fbcbdf6587457938fa122832fbe47381 100644 GIT binary patch delta 42 ycmZoMXfc@J&&atkU^gQp=VTtH37lyu#mPze`8kY}*Dy(Jp2OtDx|yBhFFybs5)Een delta 31 ncmZoMXfc@J&&aVcU^gQp$7CL+37hvad9h9`P~6PU@s}R}o`?zg diff --git a/simply-ssh/main.go b/simply-ssh/main.go index 77f7fe5..243d7a4 100644 --- a/simply-ssh/main.go +++ b/simply-ssh/main.go @@ -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) + +} \ No newline at end of file