summaryrefslogtreecommitdiff
path: root/run.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-12-16 09:36:40 -0600
committerJeff Carr <[email protected]>2023-12-16 09:36:40 -0600
commit1532d885e0e4d6de1db6075a96d1af086ff62312 (patch)
tree3288ae744c4064b8620c47568084b5db401bc879 /run.go
parenta33eca708a44bb8b9af1790413d56236dc504295 (diff)
hostname check basically workingv0.1.1
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'run.go')
-rw-r--r--run.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/run.go b/run.go
new file mode 100644
index 0000000..510007e
--- /dev/null
+++ b/run.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "strings"
+ "os/exec"
+
+ "git.wit.org/wit/shell"
+)
+
+func run(s string) string {
+ cmdArgs := strings.Fields(s)
+ // Define the command you want to run
+ // cmd := exec.Command(cmdArgs)
+ cmd := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
+
+ // Create a buffer to capture the output
+ var out bytes.Buffer
+
+ // Set the output of the command to the buffer
+ cmd.Stdout = &out
+
+ // Run the command
+ err := cmd.Run()
+ if err != nil {
+ fmt.Println("Error running command:", err)
+ return ""
+ }
+
+ tmp := shell.Chomp(out.String())
+ // Output the results
+ fmt.Println("Command Output:", tmp)
+
+ return tmp
+}
+