netcat

Is sed blocking?

徘徊边缘 提交于 2019-12-04 17:42:02
问题 I had the impression sed wasn't blocking, because when I do say: iostat | sed sed processes the data as it arrives, but when I do iostat | sed | netcat Then sed blocks netcat . Am I right? 回答1: sed will work in buffered mode when it doesn't print to a terminal. This means that it will try to fill its internal buffer before doing any processing and output by default. This is done to increase throughput, because normally in a pipe you don't care about the timing, but want as much data processed

Socket communication, Java client C server

瘦欲@ 提交于 2019-12-04 08:47:46
问题 I am trying to communicate through sockets a Java client and a C server All seems to work fine if I try the server using nc on the command line to connect or if I use nc as a server and connect with my Java client, but when I try to connect Java Client and C server it doesn't work. The client starts the connection, and sends the message, message is received by the server but then server´s response never arrives to client. Server Code: #include <stdio.h> #include <sys/types.h> #include <sys

How to send only one UDP packet with netcat?

廉价感情. 提交于 2019-12-04 07:25:39
问题 I want to send only one short value in a UDP packet, but running the command echo -n "hello" | nc -4u localhost 8000 I can see that the server is getting the hello stuff but I have to press Ctrl + c to quit the netcat command. How can I make it quit after sending hello ? Sorry, for the noise, I re-read the man page and found the -q option. echo -n "hello" | nc -4u -q1 localhost 8000 works (it quits after 1 second). For some reason it does not work with -q0 . 回答1: If you are using bash, you

Use nc to write multiple files - how?

耗尽温柔 提交于 2019-12-04 06:19:17
问题 I want to use nc as a simple TCP/IP server. So far I run it using: $ nc -k -l 3000 > temp.tmp This works, but writes all the received data of all connections into one single file. But, I would like to have individual files. Basically I get this if I skip the -k switch, but then nc shuts down as soon as the first connection is gone. How can I keep nc running, but use an individual file for each incoming request? (Or, if this is not possible, is there an alternative *nix tool that is able to do

linux script with netcat stops working after x hours

夙愿已清 提交于 2019-12-04 02:09:58
I've have to scripts: #!/bin/bash netcat -lk -p 12345 | while read line do match=$(echo $line | grep -c 'Keep-Alive') if [ $match -eq 1 ]; then [start a command] fi done and #!/bin/bash netcat -lk -p 12346 | while read line do match=$(echo $line | grep -c 'Keep-Alive') if [ $match -eq 1 ]; then [start a command] fi done I've put the two scripts in the '/etc/init.d/' When I restart my Linux machine (RasbPi), both the scripts work fine. I've tried them like 20 times, and they keep working fine. But after around 12 hours, the whole system stops working. I've put in some loggin, but it seems that

How to start REPL for slimv with MIT-Scheme

半城伤御伤魂 提交于 2019-12-04 00:03:31
My operating system is Debian Squeeze. Here's the vim version: VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jul 12 2010 02:29:33) I read a tutorial on http://kovisoft.bitbucket.org/tutorial.html and tried to start REPL for MIT-Scheme. Unfortunately, I failed to start. When I pressed ",c", it started a terminal window loading mit-scheme. Nothing showed in the REPL buffer of vim. Some errors showed in the terminal: Listening on port: 4005 ;netcat: "4005: inverse host lookup failed: Unknown host" ;To continue, call RESTART with an option number: ; (RESTART 1) => Return to read-eval-print level 1.

How to switch to netcat-traditional in Ubuntu?

痞子三分冷 提交于 2019-12-03 18:26:40
问题 I know this is a simple question, but how do I switch to netcat-traditional in ubuntu? Whenever I write netcat -h it appears that I am running netcat-openbsd instead? I'm new to Ubuntu so exact commands would be helpful. Thanks 回答1: 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

Netcat工具

时光毁灭记忆、已成空白 提交于 2019-12-03 15:25:06
一般Netcat有两个版本,一个版本是不提供反向连接的版本,一个是全功能版本。这两者的区别就是是否带-e参数,只有带-e参数的版本才支持反向连接。 参数说明 -c shell commands shell模式 -e filename 程序重定向 -b 允许广播 -d 无命令行界面,使用后台模式 -g gateway 源路由跳跃点, 不超过8 -G num 源路由指示器: 4, 8, 12, ... -h 获取帮助信息 -i secs 延时设置,端口扫描时使用 -k 设置在socket上的存活选项 -l 监听入站信息 -n 以数字形式表示的IP地址 -o file 使进制记录 -p port 本地端口 -r 随机本地和远程的端口 -q secs 在标准输入且延迟后退出(翻译的不是很好,后面实例介绍) -s addr 本地源地址 -T tos 设置服务类型 -t 以TELNET的形式应答入站请求 -u UDP模式 -v 显示详细信息 [使用=vv获取更详细的信息 -w secs 连接超时设置 -z I/O 模式 [扫描时使用] 端口扫描 nc -nv ip port nc -nvz -w 5 ip 1-65535 正向连接 将自己的Bash发送出去: nc -lp port -c bash    监听: nc ip port    反向连接 方式一、 监听: nc -lvp 7777

How to listen for multiple tcp connection using nc

风流意气都作罢 提交于 2019-12-03 14:43:15
问题 How to create a TCP connection using nc which listens to multiple hosts? nc -l -p 12345 回答1: 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. 回答2: ncat can do it. E.g. ncat --broker --listen -p 12345 will

How to send a file using netcat and then keep the connection alive?

孤街醉人 提交于 2019-12-03 13:50:31
I am issuing the command: netcat serveraddress myport < MY_FILE The thing is, that netcat sends a message to close the connection once the file is sent. I need to write messages from the console after sending that file. I remember to have done something to pipileline to stdin.. was it this? netcat serveraddress myport < MY_FILE | That isn't working now. I'm on unix. Extra info: This did not assume control on server side (E.G. use netcat on serverside to listen for the inbound connection) Perhaps you were doing: cat MY_FILE - | ncat ... (Note that I've intentionally mispelled netcat, because I