nc

在板端如何將資料copy回來


更新記錄

item note
20160816 第一版

目錄


NC

可使用busybox內建的nc指命傳送檔案

nc example (由pc listen,板端送出資料)

  • 先開啟本機的listen port
1
nc -l 6000 > image_info
  • 於板端開啟傳送
1
nc mypc.com 6000 < image_info

nc example 2 (由 板端 listen,pc接受資料)

  • 板端 (ip: a.b.c.d)

    1
    nc -l -p 6666 < file
  • pc

    1
    nc a.b.c.d 6666 > file

板端 nc command

  • arbitrary TCP and UDP connections and listens
    設定port,需要帶參數(-p)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Usage: nc [-iN] [-wN] [-l] [-p PORT] [-f FILENAME|IPADDR PORT] [-e PROG]

    Open a pipe to IP:port or file

    Options:
    -e PROG Run PROG after connect
    -i SEC Delay interval for lines sent
    -w SEC Timeout for connect
    -f FILE Use file (ala /dev/ttyS0) instead of network
    -l Listen mode, for inbound connects
    (use -l twice with -e for persistent server)
    -p PORT Local port

pc端 nc command

  • pc nc command
    最後1個參數,預設為設定port
    1
    2
    3
    4
    5
    6
    7
    8
    NC(1)                                                                        BSD General Commands Manual                                                                       NC(1)

    NAME
    nc — arbitrary TCP and UDP connections and listens

    SYNOPSIS
    nc [-46bCDdhklnrStUuvZz] [-I length] [-i interval] [-O length] [-P proxy_username] [-p source_port] [-q seconds] [-s source] [-T toskeyword] [-V rtable] [-w timeout]
    [-X proxy_protocol] [-x proxy_address[:port]] [destination] [port]

參考來源