func validateCmd(cmd string) (string, error) {
	jobs, err := jobEntries()
	if err != nil {
		return "", err
	}
	for _, job := range jobs {
		if cmd == job {
			return filepath.Join(*CmdDir, cmd), nil
		}
	}
	return "", errors.New("Command not found")
}
validates the command to be run and returns it's execution path
package main
import (
	"encoding/json"
	"errors"
	"flag"
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
	"os/exec"
	"path/filepath"
	"strconv"
	"strings"
	"sync"
	"time"
)
var CmdDir = flag.String("dir", "./cmds", "Commands dir")
var ExcludePat = flag.String("exclude", "",
	"Exclude shell file name pattern. Ex: *.pyc,a.out")
var commandLock *sync.Mutex
func jobEntries() ([]string, error) {
	var entries []string
	dir, err := os.Open(*CmdDir)
	if err != nil {
		return entries, err
	}
	defer dir.Close()
	dirInfoSlice, _ := dir.Readdir(-1)
	for _, fileinfo := range dirInfoSlice {
		fileName := fileinfo.Name()
		excludes := strings.Split(*ExcludePat, ",")
		matched := false
		for _, exclude := range excludes {
			matched, _ = filepath.Match(exclude, fileName)
			if matched {
				break
			}
		}
		if !matched {
			entries = append(entries, fileName)
		}
	}
	return entries, nil
}