读取CSV文件,转换map数据。文件上传scp

This commit is contained in:
TsMask
2023-09-11 21:03:53 +08:00
parent 614e792670
commit f9596f6363
3 changed files with 97 additions and 0 deletions

22
lib/core/file/ssh.go Normal file
View File

@@ -0,0 +1,22 @@
package file
import (
"fmt"
"os/exec"
"ems.agt/lib/core/conf"
)
// 网元NE 文件复制到远程文件夹
func FileNeSCP(neIp, filePath, dstPath string) error {
usernameNe := conf.Get("ne.user").(string)
// scp /path/to/local/file.txt user@remote-server:/path/to/remote/directory/
dstDir := fmt.Sprintf("%s@%s:%s", usernameNe, neIp, dstPath)
cmd := exec.Command("scp", "-r", filePath, dstDir)
out, err := cmd.CombinedOutput()
if err != nil {
return err
}
fmt.Println(out)
return nil
}