summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openBrowser.go42
-rw-r--r--run.go11
2 files changed, 51 insertions, 2 deletions
diff --git a/openBrowser.go b/openBrowser.go
new file mode 100644
index 0000000..2977cef
--- /dev/null
+++ b/openBrowser.go
@@ -0,0 +1,42 @@
+package shell
+
+import (
+ "os/exec"
+ "runtime"
+
+ "go.wit.com/log"
+)
+
+// openBrowser opens the specified URL in the default browser of the user.
+func OpenBrowser(url string) error {
+ var cmd string
+ var args []string
+
+ switch runtime.GOOS {
+ case "windows":
+ cmd = "cmd"
+ args = []string{"/c", "start"}
+ case "darwin":
+ cmd = "open"
+ default: // "linux", "freebsd", "openbsd", "netbsd"
+ cmd = "xdg-open"
+ }
+ args = append(args, url)
+ return exec.Command(cmd, args...).Start()
+}
+
+func Xterm(cmd string) {
+ var tmp []string
+ var argsXterm = []string{"nohup", "xterm", "-geometry", "120x40"}
+ /*
+ if xtermHold.Checked() {
+ log.Println("hold = true")
+ argsXterm = append(argsXterm, "-hold")
+ } else {
+ log.Println("hold = false")
+ }
+ */
+ tmp = append(argsXterm, "-e", cmd)
+ log.Info("xterm cmd=", tmp)
+ go Run(tmp)
+}
diff --git a/run.go b/run.go
index 4e03ac2..15e4633 100644
--- a/run.go
+++ b/run.go
@@ -68,10 +68,17 @@ func RunPath(path string, args []string) bool {
cmd.Dir = path
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
- println("path =", path, "cmd =", strings.Join(args, " "))
+ log.Info("path =", path, "cmd =", strings.Join(args, " "))
if err := cmd.Run(); err != nil {
// Handle error if the command execution fails
- println("Error executing command:", err.Error())
+ log.Info("RunPath() failed")
+ // log.Info("cmd.Enviorn =", cmd.Environ())
+ out, outerr := cmd.Output()
+ log.Info("cmd.output =", out)
+ log.Info("cmd.output err=", outerr)
+ log.Info("path =", path)
+ log.Info("args =", args)
+ log.Info("err =", err.Error())
return false
}
return true