diff options
| author | horus_arch | 2015-03-15 20:51:57 +0100 |
|---|---|---|
| committer | horus_arch | 2015-03-15 20:51:57 +0100 |
| commit | f964301365c314b388314551f73ea69e9e51df47 (patch) | |
| tree | 3b9f0fd9ddceac8dae3d261f71a315e10a22c359 | |
| parent | fa9dd55107dd08830b2dc5e4cf52674ff19981cf (diff) | |
| download | monotond-f964301365c314b388314551f73ea69e9e51df47.tar.gz | |
| -rw-r--r-- | monotond.go (renamed from monoton.go) | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -12,27 +12,32 @@ import ( func main() { time_f := flag.String("time", "1m", "Set the time interval.") cmd_f := flag.String("cmd", "", "Execute the command.") - vars_f := flag.String("vars", "", "Command line options for the programm.") + args_f := flag.String("args", "", "Command line options for the programm.") flag.Parse() var ( - time, cmd, vars string + time, cmd, args string ) time = fmt.Sprintf("@every %s", *time_f) cmd = fmt.Sprintf("%s", *cmd_f) - vars = fmt.Sprintf("%s", *vars_f) + args = fmt.Sprintf("%s", *args_f) cmd, err := exec.LookPath(cmd) if err != nil { - log.Printf("Executable (%s) neither found in PATH variable nor in working directory.\n", *cmd_f) - os.Exit(1) + cmd = fmt.Sprintf("%s", *cmd_f) + cmd, err = exec.LookPath("./" + cmd) + if err != nil { + log.Println(err) + log.Printf("Executable (%s) neither found in PATH variable nor in working directory.\n", *cmd_f) + os.Exit(1) + } } job := cron.New() job.AddFunc(time, func() { - if vars == "" { + if args == "" { c := exec.Command(cmd) o, err := c.Output() if err != nil { @@ -40,7 +45,7 @@ func main() { } fmt.Printf("%s", o) } else { - c := exec.Command("bash", "-c", cmd+" "+vars) + c := exec.Command("bash", "-c", cmd+" "+args) o, err := c.Output() if err != nil { log.Println(err) |
