NC use 2, use NC transfer files and directory

Using NC transport files is more convenient because it does not use SCP and RSYNC input password.

Send the RPM file on device A to device B

Pay attention to the process order, the receiver listens on the port first, and the sender sends data to the port of the device where the receiver is located.

Step 1, first start to monitor the receiving file on machine B, the format is as follows

This means that the data received by LAI 9995 is recorded in a file file (here the file name is optional)

nc -l port > file

nc -l 9995 > zabbix.rpm

8692e7351d097c172a65d1bd61b38992

Step 2Send data to device port 9995 on the device, and send the next RPM packet to the past

nc 10.0.1.162 9995

f63685ed47c96b77016e2d4bef758898

After device B is received, it automatically exits monitoring. The file size is the same as the device size.

e9c94b85ff086da6f8b0e6477ea02dc9

Method 2, transfer files (run send command first)

Step 1, first run the file command on device b

The following command specifies that the test.mv file is sent on local port 9992

nc-l 9992

48818583b56f7a0e3510a474068cc2cf

Step 2, connect device B to device, take the receiving file

The following command indicates that the file is obtained by plugging into port 9992 of device B and the file is stored in this directory. File name – test2.mv

nc 10.0.1.162 9992>test2.mv

f23f66800215c9f421de17baf0614bae

Method 3: View the transfer directory (the method for sending files is the same)

Step 1, B device starts the screen first, as below

Device sends multiple files to device B.

The move directory must be combined with other commands such as tar

Following my test pipeline, another filename should not be configured

nc -l 9995 | tar xfvz –

449dd47d3579c3baa232853cfb654fe5

Step 2, the machine filling file and connect the machine B port

Before piping, this means that all files in the current directory are packed in – then use NC to send them to device B

tar cfz – * | nc 10.0.1.162 9995

6362857e67a9647276a371836b1f6607

The machine is received here and decompressed automatically

c48c9331e9f572f22b5dd9dd489b330b

Leave a Comment