diff options
| author | Jeff Carr <[email protected]> | 2023-12-16 09:36:40 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-12-16 09:36:40 -0600 |
| commit | e9f1723dbc8dab3bd84f7006723f6ae9c97df88c (patch) | |
| tree | 347243f04017721251f61292646c75cf307b2d1a /run.go | |
| parent | 27696b976485f989d664f330e9c328de93e8e672 (diff) | |
hostname check basically working
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'run.go')
| -rw-r--r-- | run.go | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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 +} + |
