示例#1
0
文件: master.go 项目: spicavigo/gomr
func (m *Master) scpFile(path string, dest string, destPath string) {

	sshConn := util.GetSSHConn(strings.Split(dest, ":")[0], m.Username, m.PEMFile)
	scpConn := goscplib.NewScp(sshConn)
	scpConn.PushFile(path, destPath)
	sshConn.Close()
}
示例#2
0
文件: wassh.go 项目: postfix/waSSH
func executeScp(res chan string, server string, src string, dest string) {
	conn, _ := Connect(server, *user, *pwd)
	scp := goscplib.NewScp(conn)
	fileSrc, srcErr := os.Open(src)
	if srcErr != nil {
		fmt.Println("Failed to open source file: " + srcErr.Error())
	}
	//Check if src is a dir
	srcStat, statErr := fileSrc.Stat()
	if statErr != nil {
		fmt.Println("Failed to stat file: " + statErr.Error())
	}
	if srcStat.IsDir() {
		scp.PushDir(src, dest)
	} else {
		scp.PushFile(src, dest)
	}
	if res != nil {
		res <- "\033[1m\033[92m" + server + ":\033[0m \n scp " + src + " to " + dest + "\n"
	}
}