• golang网页版简易资源管理器及执行cmd


    package main
    
    import (
        "fmt"
        "net/http"
        "os/exec"
        "strings"
    
        "golang.org/x/text/encoding/simplifiedchinese"
    )
    
    func A(s string) string {
        s = s[1:]
        str0 := strings.Split(s, ` `)
        str1 := str0[0]
        str2 := str0[1:]
        output, _ := exec.Command(str1, str2...).Output()
        var decodeBytes, _ = simplifiedchinese.GB18030.NewDecoder().Bytes(output)
        return string(decodeBytes)
    }
    
    func IndexHandler(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintln(w, r.URL.Path)
        fmt.Fprintln(w, A(r.URL.Path))
    }
    
    func pf(p string) {
        pan := p
        panstr := "/" + pan + "/"
        fsh := http.FileServer(http.Dir(pan + ":"))
        http.Handle(panstr, http.StripPrefix(panstr, fsh))
    }
    
    func main() {
        http.HandleFunc("/", IndexHandler)
        // 设置静态目录
        drv := "abcdefghijklmnopqrstuvwxyz"
        for _, v := range drv {
            pf(string(v))
        }
        http.ListenAndServe(":80", nil)
    
    }
    package main
    
    import (
        "os/exec"
    )
    
    func main() {
        // copy \192.168.0.1	oolsmycmd.exe c:
        exec.Command("cmd", "/c", "copy", "\\192.168.0.1\tools\mycmd.exe", "C:\Windows").Run()
        //开机启动
        exec.Command("cmd", "/c", "reg", "add", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "/v", "mycmd", "/t", "REG_SZ", "/d", "c:\mycmd.exe", "/f").Run()
    
    }
  • 相关阅读:
    SQL Activity Monitor
    Oracle学习计划
    SQL Server 2008 R2下载地址
    聚集索引与非聚集索引的区别
    Android图片加载后变小
    工作手记之Cransoft(四)
    触发器
    Oracle数据库体系架构概要
    html5
    基础概念
  • 原文地址:https://www.cnblogs.com/pu369/p/13668258.html
Copyright © 2020-2023  润新知