diff options
| author | Jeff Carr <[email protected]> | 2024-12-18 17:59:01 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-18 17:59:01 -0600 |
| commit | 3408d9434b9f1316f4391a335bffc30f8a09bad4 (patch) | |
| tree | 99056178f4573748a9a76e5385a62f232c357da7 | |
| parent | d564d4f2d743712a2fe2a35177edfdf97dc9c10b (diff) | |
purge old codev0.22.19
| -rw-r--r-- | posix.go (renamed from old.go) | 87 | ||||
| -rw-r--r-- | structs.go | 9 |
2 files changed, 7 insertions, 89 deletions
@@ -3,8 +3,6 @@ package shell // old code and probably junk import ( - "io/ioutil" - "net/http" "os" "os/exec" @@ -16,11 +14,11 @@ import ( var callback func(interface{}, int) -var shellStdout *os.File -var shellStderr *os.File +// var shellStdout *os.File +// var shellStderr *os.File -var spewOn bool = false -var quiet bool = false +// var spewOn bool = false +// var quiet bool = false // var msecDelay int = 20 // number of milliseconds to delay between reads with no data @@ -42,26 +40,6 @@ func InitCallback(f func(interface{}, int)) { callback = f } -// this means it won't copy all the output to STDOUT -func Quiet(q bool) { - quiet = q -} - -/* -func Script(cmds string) int { - // split on new lines (while we are at it, handle stupid windows text files - lines := strings.Split(strings.Replace(cmds, "\r\n", "\n", -1), "\n") - - for _, line := range lines { - line = Chomp(line) // this is like 'chomp' in perl - log.Log(INFO, "LINE:", line) - time.Sleep(1) - RunString(line) - } - return 0 -} -*/ - func Unlink(filename string) bool { if err := os.Remove(filename); err != nil { return Exists(filename) @@ -107,66 +85,11 @@ func Exists(filename string) bool { return true } -// makes the directory -func Mkdir(dir string) bool { - if Dir(dir) { - // already a dir - return true - } - if Exists(dir) { - // something else is there - return false - } - Run([]string{"mkdir", "-p", dir}) - return true -} - -func IsDir(dirname string) bool { - return Dir(dirname) -} - // return true if the filename exists (cross-platform) -func Dir(dirname string) bool { +func IsDir(dirname string) bool { info, err := os.Stat(Path(dirname)) if os.IsNotExist(err) { return false } return info.IsDir() } - -// Cat a file into a string -func Cat(filename string) string { - buffer, err := ioutil.ReadFile(Path(filename)) - // log.Log(INFO, "buffer =", string(buffer)) - if err != nil { - return "" - } - return string(buffer) -} - -func RunPathHttpOut(path string, cmd []string, w http.ResponseWriter, r *http.Request) error { - log.Warn("Run(): ", cmd) - - process := exec.Command(cmd[0], cmd[1:len(cmd)]...) - process.Dir = path - process.Stderr = os.Stderr - process.Stdin = r.Body - process.Stdout = w - process.Start() - err := process.Wait() - log.Warn("shell.Exec() err =", err) - return err -} - -func RunHttpOut(cmd []string, w http.ResponseWriter, r *http.Request) error { - log.Warn("NewRun() ", cmd) - - process := exec.Command(cmd[0], cmd[1:len(cmd)]...) - process.Stderr = os.Stderr - process.Stdin = r.Body - process.Stdout = w - process.Start() - err := process.Wait() - log.Warn("shell.Exec() err =", err) - return err -} @@ -1,12 +1,6 @@ package shell -import ( - "bufio" - "bytes" - "io" - "os/exec" -) - +/* var FileMap map[string]*File var readBufferSize int @@ -54,3 +48,4 @@ func New() *OldShell { return &tmp } +*/ |
