Netcat is a computer networking service for reading from and writing network connections using TCP or UDP

learn more… | top users | synonyms

13
votes
2answers
12k views

/dev/tcp listen instead of nc listen

With a netcat listener like: nc -l <port> < ~/.bashrc I can grab my .bashrc on a new machine (doesn't have nc or LDAP) with: cat < /dev/tcp/<ip>/<port> > ~/.bashrc My ...
12
votes
1answer
5k views

Remote desktop over SSH reverse tunnel to replace TeamViewer

I want to open a remote desktop session from my laptop to desktop over my SSH (reverse) tunnel. That should be simple (or at least doable), right? Until now I've been using Team Viewer to log in to ...
10
votes
3answers
17k views

convert a hex string to binary and send with netcat

I have a binary file that I can send with netcat: $ nc -l localhost 8181 < my.dat The file contains this: $ xxd my.dat 0000000: 0006 3030 3030 4e43 ..0000NC What I really ...
8
votes
4answers
1k views

Simplest way to send files over network

What is the simplest and most versatile way to send files over the network to other computers? By that I mean computers that other people are using at the moment. I don't think SSH works if the ...
8
votes
3answers
7k views

Using in/out named pipes for a TCP connection

I've been fiddling with getting this to work for a while now, so I suspect some sort of fundamental misunderstanding about how pipes work is the root cause of my troubles. My goal is to initiate a ...
6
votes
4answers
452 views

How to grep netcat output

I'm trying to grep live text stream from netcat, but it doesn't work for me: netcat localhost 9090 | grep sender returns nothing, but I'm sure that it should. If I redirect the netcat output to a ...
6
votes
2answers
4k views

Howto create a permanent client connection with netcat?

I'm writing a bash script that constantly read a folder in a loop to send data to a server at a defined time interval. I'm using netcat as the tool to connect to the server and send the data. My ...
4
votes
2answers
8k views

How to make netcat use an existing HTTP proxy

I can access a web page just fine by directly hitting my web server as follows: $ echo "GET /sample" | nc web-server 80 This is contents of /sample... $ Now, I would like netcat to go via a Squid ...
4
votes
2answers
657 views

is it possible to send the remote connector ip via netcat?

Actually I want to make something like ifconfig.me functionality but only for my internal network. I see it the way smth on server listens some port and send ip of connected remote machine. Seems nc ...
4
votes
2answers
662 views

Why does this shell snippet to check if hosts are up using netcat stop prematurely?

Q: Why does the second iteration exits after 10.175.192.16? Can someone explain that? Or I just found a "while/netcat" bug? a.txt's content: $ cat a.txt 10.175.192.14 10.175.192.16 10.175.192.17 $ ...
4
votes
1answer
5k views

netcat in shell script giving invalid connection

I have a shell script that uses netcat to listen to localhost on port 1111 for web requests. Every time I try accessing localhost:1111/index.html for example I get: invalid connection to [127.0.0.1] ...
3
votes
3answers
1k views

How can I read lines at a fixed speed?

I need to read a large log file and send it over a local network using (netbsd) netcat between two VMs on the same host workstation. I know that netcat has an interval, but as far as I can tell, the ...
3
votes
2answers
4k views

SSH jumping over socks(4/5) proxy chain. Host -> socks proxy -> socks proxy -> destination

I got a great answer for my previous question about connecting from Machine A to Machine C via Socks proxy located on Machine B. Say Machine B Ip is 218.62.97.105 and it is listening on port 1080 ...
3
votes
3answers
3k views

Test if telnet port is active within a shell script

I am trying to create a script to test whether it is possible to login via telnet. I do not want to really log in; therefore, expect is not needed. I just want to see if I am able to get a login ...
3
votes
2answers
720 views

Different redirection styles with netcat and tee giving different results

In trying to trace a simple HTTP GET request and its response with nc, I'm running into something strange. This, for example, works fine: the in file ends up containing the HTTP GET request and the ...
3
votes
1answer
3k views

Stream Video using Netcat and VLC

I'm trying to use netcat on Linux server to stream video to my windows client using VLC I started running netcat on Linux: cat /media/HD1/myMovie.mkv | nc -l 8668 In VLC Windows Client I tried ...
3
votes
0answers
128 views

Remote Mouse netcat (/dev/input/mice)

I was playing around with nc and I'm discovering how powerful and versatile this tool is. I was wondering how the file /dev/input/mice works because when I do cat /dev/input/mice you see the output, ...
2
votes
2answers
8k views

nc: bind failed: Address already in use

I am trying to execute nc command from a script , my script is executing nc command on different ports of Destination using the same source port. e.g: nc -p 8140 -z -v -n 10.X.X.9 9090 nc -p 8140 -z ...
2
votes
1answer
175 views

How to avoid sending EOF from a script parsing requests from and sending answers to netcat

I made a simple server using netcat and backpipe: mkfifo backpipe nc -l 8080 < backpipe | parseRequests.sh > backpipe The contents of "parseRequests.sh" is just: #!/bin/sh if [ "$1" = "1+1" ...
2
votes
1answer
1k views

Netcat (nc6) - Minimal IPv6 only TCP Server and Client

Im am trying to set up a basic IPv6 only echo-server using netcat (or rather nc6). Client and server are both in the same local network. However, the client quits immediately: IPv6-Server: $ nc6 ...
2
votes
2answers
48 views

Output of one command is piped to another one; how to close both?

I call Qt Assistant like suggested on stackoverflow: nc -lkU ~/.assistantfifo | assistant -enableRemoteControl & Qt Assistant window is opened, and if I call jobs, it returns: [1] + running ...
2
votes
1answer
1k views

cat file to udp, pt 2: send 1 udp packet per ^C-delimited line

Yesterday I asked a question about catting a file over a UDP socket in bash. The solution we came up was netcat -c -w 1 -v -u -s 127.0.0.1 239.255.0.1 30001 < test.txt. This worked in the sense ...
2
votes
3answers
514 views

Servers running from chrooted Ubuntu on HP TouchPad? [closed]

The problem: servers appear to be broken inside my Ubuntu chroot. No matter what kind of server I try to run, they all seem unresponsive (VLC server won't respond to client, mkRemote doesn't move the ...
2
votes
2answers
68 views

How to write to a file with netcat? And set it to grow to a certain size and begin overwriting itself?

I'm currently writing a program that prints to a Zebra printer. Because my office doesn't have a zebra printer, we print to a linux VM running netcat with nc -k -l -p 9100 | tee labels.txt so that we ...
2
votes
1answer
301 views

nc -l in background closes immediately (nc -l 1234 &)

When I put this nc -l 12345 >nc_out in a shell script, run it and then connect from other shell using telnet, it allows me to type some text and have it end up in nc_out. But if I start nc in ...
2
votes
3answers
1k views

netcat doesn't work as expected when detached from console with nohup (Ubuntu/Debian 64bit)

I'm trying to leave netcat running and close the ssh session (even stop the ssh daemon). But it then exits before all of the data is written. I'm testing in a non-ssh (local) console: nohup nc -l -p ...
2
votes
1answer
4k views

How to put value of echo pipe netcat commands into variable [duplicate]

I have this command succession: echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567 and let's say it return a string like, for example "Hello...bla". (on the 89.196.167.2 i have made a server ...
2
votes
1answer
57 views

Jumping ssh hosts without netcat

I have access to an intermediate server to which I can connect with ssh. From there I can connect to other servers: A→B→C, where A is my laptop, B is an intermediate server accepting connections from ...
2
votes
1answer
133 views

Log from TCP Port breaking messages on characters other than newline

I'm working on a set of scripts to monitor some external services that log to a TCP port. function handleMessage { while read message do # Handle $message done } nc -d $ipadd $port | ...
2
votes
2answers
805 views

How to copy a partition over network

I want to copy a Windows 7 partition that came installed on my laptop to my desktop computer. I've tried: # bzip2 -c /dev/sda5 | nc 192.168.1.1 2222 # on laptop # nc -l 2222 | bzip2 -d > ...
1
vote
2answers
152 views

netcat to capture ethernet

How can I make sure the result of the following command: nc eth0 &> capture.txt would capture the data + errors transmitted via eth0?
1
vote
2answers
157 views

nc command's -k option

man page of the nc command has following information -k Forces nc to stay listening for another connection after its current connection is completed. It is an error to use ...
1
vote
1answer
85 views

Write output from netcat to a file

I'm currently trying to write a scan port result to a text file Here is the command I tried to use: nc -vv -z localhost 1-80 > file.txt This doesn't work (that is, the error messages from nc ...
1
vote
1answer
61 views

What does the %h and %p do in this command?

$ ssh -o User=fred -o ProxyCommand="nc -X 5 -x localhost:9150 %h %p" server.example.org It's from http://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts I can't find any comments about ...
1
vote
3answers
341 views

nc not waiting for server disconnect on OS X

How to make nc client on OS X Mavericks keep socket open and read data until server disconnects the socket? I want to send data to a server through nc and then use the response. Problem is that nc ...
1
vote
1answer
1k views

netcat echo server - possible with pipes instead of commands as strings?

I want to create an echo server without specifying any of my commands inside strings. I want all commands to be connected by pipes. This doesn't appear possible because the response gets returned ...
1
vote
1answer
1k views

Command line streaming string manipulation from netcat

I have a netcat udp connection listening with nc -l -u .... I've been trying to do a per packet manipulation of the incoming data with just command line, but it doesn't look like there is a flag in ...
1
vote
2answers
42 views

Using netcat to launch a program? [duplicate]

Assume I let netcat listen on some port on PC1 (IP:10.0.0.1) with: PC1:~$ nc -l 9999 I connect from PC2 (IP:10.0.0.2) and send some strings: PC2:~$ nc 10.0.0.1 9999 hello touchit test ...
1
vote
1answer
200 views

tcpdump and nc with udp

I don't understand the behaviour of netcat. Let's say that I have one host acting as server: [root@localhost tmp]# nc -u -l -p 670 Then I try to connect from a client: root@debian:/tmp# nc -u ...
1
vote
3answers
723 views

How can I pipe data over network or serial to the display of another linux machine?

I have a second monitor that I'd like to use for a text-based debugging log and/or console. I don't want to have it as part of my GUI / "desktop" / main system. I have this display connected to an ...
1
vote
1answer
445 views

netcat throughput low but iperf high [closed]

I was testing the throughput between two pcs connected on the same router: one with 100mbps lan, the other with 54mbps wifi. I tested both netcat and iperf and the throughtput I get is only 2.6mb/s. ...
1
vote
1answer
49 views

Need help using Netcat

I have a file on my server that has HL7 messages spread out by a space. Example below. I am wanting to send one of these messages at a time in a continual loop until stopping the script with ctrl+c. I ...
1
vote
0answers
109 views

'nc' using ~100% CPU when transferring a FIFO file

On the server which is always connected I’m using this in a crontab: @reboot nc -k -l 1337 < /tmp/fifo.fifo On the client which is not always on the network or switched on I’m using this ...
1
vote
0answers
49 views

Pipe a device via USB or wlan

I have an Android phone and I want to use some of its onboard device from PC. To be more clear, there is a node in /dev/ and I want to have on PC a file (or named pipe which is accessable as a file) ...
1
vote
1answer
63 views

NetCat never ending http session

I'm trying to use netcat to server some bash command results via a web interface, that stays running. The page is dynamic and needs to be updated upon loading. Just an example with what I'm using: ...
1
vote
2answers
72 views

Capturing data from a Fluke 1620a via netcat

I am trying to pull temperature and humidity data from Fluke DewK 1620a thermo-hygrometers and write the temp/humidity readings to a log. I can connect to the device via netcat with a simple 'nc ...
1
vote
0answers
38 views

How to make netcat print colourful text?

on my Mac I have an peripheral that sends text data to localhost:2332. Some of them are coloured, like this: "\e[1;31mRed text here\e[m normal text here", I use nc loacal host to monitor the data ...
0
votes
2answers
45 views

Is there a netcat like utility that uses unix sockets?

netcat is wonderful, let me count the ways -- is to much let me sum up -- tcp/ip4, udp/ip4, tcp/ip6, udp/ip6, but what I need is stream/unix. I could write it in half a day, but If someone has already ...
0
votes
1answer
2k views

nc command not found on SuSE

I'm trying to use the nc command on SuSE Linux Enterprise Desktop 11. I executed this line: nc ­-4ul 192.0.2.2 50000 But I got this.- bash: nc: command not found This is the first time that I ...
0
votes
1answer
25 views

Can you force netcat to succeed only if all ports in port range succeed?

I use nc as part of a verification script, and check the output of each nc command listed against what the expected output should be. e.g., nc -zvw1 serv1.host.com 443 | gawk '{print $7}' Expected ...