finish upload function
This commit is contained in:
30
console.go
30
console.go
@@ -292,29 +292,19 @@ func sender(conn *net.TCPConn, exit chan string, receive chan int) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.Write([]byte("dd of=" + args[2] + " status=none" + "\n"))
|
|
||||||
uploadbuf, _ := os.ReadFile(args[1])
|
uploadbuf, _ := os.ReadFile(args[1])
|
||||||
// cmd := append([]byte("dd if="), uploadbuf...)
|
file, _ := os.Stat(args[1])
|
||||||
// cmd1 := append(cmd, []byte("|dd of="+args[2]+" status=none\n")...)
|
size := file.Size()
|
||||||
//conn.Write([]byte(""))
|
count := size / 1024
|
||||||
// conn.Write([]byte("echo "))
|
morecount := size % 1024
|
||||||
|
if morecount != 0 {
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
strcount := strconv.Itoa(int(count))
|
||||||
|
conn.Write([]byte("dd of=" + args[2] + " status=none bs=1024 count=" + strcount + "\n"))
|
||||||
conn.Write(uploadbuf)
|
conn.Write(uploadbuf)
|
||||||
conn.CloseWrite()
|
fmt.Print("Upload success")
|
||||||
//conn.Write([]byte("|dd of=" + args[2]))
|
|
||||||
//conn.Write([]byte(">" + args[2]))
|
|
||||||
//n, _ := conn.Write(uploadbuf)
|
|
||||||
// fmt.Print(n)
|
|
||||||
// fmt.Print(len(uploadbuf))
|
|
||||||
// if n == len(uploadbuf) {
|
|
||||||
// // fmt.Println("failed to upload")
|
|
||||||
// // fmt.Print(env1.username + " > ")
|
|
||||||
// fmt.Print(env1.username + " > ")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
fmt.Print(env1.username + " > ")
|
fmt.Print(env1.username + " > ")
|
||||||
receive <- 1
|
|
||||||
// fmt.Println("failed to upload")
|
|
||||||
// fmt.Print(env1.username + " > ")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user