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)
|
||||
}
|
||||
|
||||
conn.Write([]byte("dd of=" + args[2] + " status=none" + "\n"))
|
||||
uploadbuf, _ := os.ReadFile(args[1])
|
||||
// cmd := append([]byte("dd if="), uploadbuf...)
|
||||
// cmd1 := append(cmd, []byte("|dd of="+args[2]+" status=none\n")...)
|
||||
//conn.Write([]byte(""))
|
||||
// conn.Write([]byte("echo "))
|
||||
file, _ := os.Stat(args[1])
|
||||
size := file.Size()
|
||||
count := size / 1024
|
||||
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.CloseWrite()
|
||||
//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("Upload success")
|
||||
fmt.Print(env1.username + " > ")
|
||||
receive <- 1
|
||||
// fmt.Println("failed to upload")
|
||||
// fmt.Print(env1.username + " > ")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user