How to switch to netcat-traditional in Ubuntu?

enable universe repository (if not enabled) sudo add-apt-repository universe Install the other netcat using synaptic. (To do this, the universe repository must be enabled.) sudo apt-get install netcat-traditional type sudo update-alternatives –config nc Select the option /bin/nc.traditional type nc -h output: [v1.10-38] connect to somewhere: nc [-options] hostname port[s] [ports] … listen for inbound: nc … Read more

How can I close a netcat connection after a certain character is returned in the response?

Create a bash script called client.sh: #!/bin/bash cat someFile while read FOO; do echo $FOO >&3 if [[ $FOO =~ `printf “.*\x00\x1c.*”` ]]; then break fi done Then invoke netcat from your main script like so: 3>&1 nc -c ./client.sh somehost 1234 (You’ll need bash version 3 for the regexp matching). This assumes that the … Read more

Strange behaviour of netcat with UDP

When nc is listening to a UDP socket, it ‘locks on’ to the source port and source IP of the first packet it receives. Check out this trace: socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 3 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 bind(3, {sa_family=AF_INET, sin_port=htons(10000), sin_addr=inet_addr(“127.0.0.1”)}, 16) = 0 recvfrom(3, “f\n”, 2048, MSG_PEEK, {sa_family=AF_INET, sin_port=htons(52832), sin_addr=inet_addr(“127.0.0.1”)}, [16]) … Read more

How to listen for multiple tcp connection using nc

Simultaneous connections are not possible with netcat. You should use something like ucspi-tcp‘s tcpserver tool or leverage xinetd since you’re on Linux. See: https://superuser.com/questions/232747/netcat-as-a-multithread-server Consecutive connections could be handled through a shell script that restarts netcat after it finishes.

Netcat implementation in Python

Does it work if you just use nc? I think you should try something a little simpler: import socket def netcat(hostname, port, content): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((hostname, port)) s.sendall(content) s.shutdown(socket.SHUT_WR) while 1: data = s.recv(1024) if len(data) == 0: break print(“Received:”, repr(data)) print(“Connection closed.”) s.close() I added the shutdown call because maybe your device … Read more

How can I tail a remote file?

Have you tried ssh -t remotemachine <some command> -t option from the ssh man page: -t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty. … Read more

How to make an Echo server with Bash?

If you use ncat instead of nc your command line works fine with multiple connections but (as you pointed out) without -p. ncat -l 2000 -k -c ‘xargs -n1 echo’ ncat is available at http://nmap.org/ncat/. P.S. with the original the Hobbit’s netcat (nc) the -c flag is not supported. Update: -k (–keep-open) is now required … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)