@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/mudler/LocalAGI/core/types"
|
"github.com/mudler/LocalAGI/core/types"
|
||||||
"github.com/mudler/LocalAGI/pkg/config"
|
"github.com/mudler/LocalAGI/pkg/config"
|
||||||
@@ -165,12 +166,15 @@ func sshCommand(privateKey, command, user, host string) (string, error) {
|
|||||||
defer session.Close()
|
defer session.Close()
|
||||||
|
|
||||||
// Run a command
|
// Run a command
|
||||||
output, err := session.CombinedOutput(command)
|
cmdOut, err := session.CombinedOutput(command)
|
||||||
if err != nil {
|
result := string(cmdOut)
|
||||||
return "", fmt.Errorf("failed to run: %v", err)
|
if strings.TrimSpace(result) == "" {
|
||||||
|
result += "\nCommand has exited with no output"
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
return string(output), nil
|
result += "\nError: " + err.Error()
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ShellAction) Plannable() bool {
|
func (a *ShellAction) Plannable() bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user