netcat

How to respond conditionally based on the request when using netcat

一世执手 提交于 2019-11-30 04:48:27
问题 I am trying to set up a web server using only windows batch scripting. I have already come up with the following script: @echo off @setlocal enabledelayedexpansion for /l %%a in (1,0,2) do ( type tempfile.txt | nc -w 1 -l -p 80 | findstr mystring if !ERRORLEVEL! == 0 ( echo found > tempfile.txt ) else ( echo not-found > tempfile.txt ) ) However, the response is always one request behind, I mean, if I type something like this into the browser: REQUEST: localhost/mystring I will get the

Send POST request with netcat

狂风中的少年 提交于 2019-11-29 23:49:40
I have found this little script in PHP that send a simple request to twitter for update your status, I have tried this: http://pratham.name/twitter-php-script-without-curl.html , and it work. Now, I want send this request with netcat, but this doesn't work, why? I send request in this way: echo -e $head | nc twitter.com 80 The $head are my header that I have tried with also PHP, so it are right. Anyone know how I can make this? Thanks to all. edit. head="POST http://twitter.com/statuses/update.json HTTP/1.1\r\n Host: twitter.com\r\n Authorization: Basic myname:passwordinbs64\r\n Content-type:

How to switch to netcat-traditional in Ubuntu?

荒凉一梦 提交于 2019-11-29 21:27:47
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 totox 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]

Flume 入门

[亡魂溺海] 提交于 2019-11-29 21:03:06
1 Flume 概述 1.1 定义 Flume 是 Cloudera 提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统; Flume 基于流式架构,灵活简单。 1.2 特点 可以和任意存储进程集成 输入的的数据速率大于写入目的存储的速率, Flume 会进行缓冲,减小 HDFS 的压力 Flume 中的事务基于 Channel ,使用了两个事务模型( sender + receiver ),确保消息被可靠发送 Flume 使用两个独立的事务分别负责从 Soucrce 到 Channel ,以及从 Channel 到 Sink 的事件传递。一旦事务中所有的数据全部成功提交到 Channel ,那么 Source 才认为该数据读取完成,同理,只有成功被 Sink 写出去的数据,才会从 Channel 中移除 1.3 组成架构 1.3.1 Agent Agent 是一个 JVM 进程,它以事件的形式将数据从源头传递到目的地 Agent 主要由 Source 、 Channel 、 Sink 组成 1.3.2 Source Source 是负责接收数据到 Agent 的组件,可以处理各种类型,包括 avro 、 thrift 、 exec 、 jms 、 spooling directory 、 netcat 、 sequence generator 、 syslog

How to make an Echo server with Bash?

大憨熊 提交于 2019-11-29 20:46:33
How to write a echo server bash script using tools like nc, echo, xargs, etc capable of simultaneously processing requests from multiple clients each with durable connection? The best that I've came up so far is nc -l -p 2000 -c 'xargs -n1 echo' but it only allows a single connection. 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

Executing script on receiving incoming connection with xinetd

喜夏-厌秋 提交于 2019-11-29 08:13:35
I want xinetd to execute a shell script when a connection is received on a certain port. To accomplish this, followed this tutorial: [enter link description here][1] Unfortunately, the whole thing doesn't work as I hoped that's why I am going to show you my configuration. The script that is called by xinetd is located at /usr/local/bin. It can be executed without any problems: #!/bin/bash echo "connection received" /etc/xinetd.d/testservice has this content: service testservice { disable = no socket_type = stream protocol = tcp port = 5900 log_on_success += USERID log_on_failure += USERID

Strange behaviour of netcat with UDP

喜欢而已 提交于 2019-11-28 18:37:46
I noticed a strange behaviour working with netcat and UDP. I start an instance (instance 1) of netcat that listens on a UDP port: nc -lu -p 10000 So i launch another instance of netcat (instance 2) and try to send datagrams to my process: nc -u 127.0.0.1 10000 I see the datagrams. But if i close instance 2 and relaunch again netcat (instance 3): nc -u 127.0.0.1 10000 i can't see datagrams on instance 1's terminal. Obsiously the operating system assigns a different UDP source port at the instance 3 respect to instance 2 and the problem is there: if i use the same instance'2 source port (example

How to wait for an open port with netcat?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 17:12:23
I'm trying to do a custom dockerfile with jenkins on it. I would to wait until port 8080 is open instead of doing an ugly 'sleep 60' with netcat but in not very confident with bash scripts and netcat. Here is an example of what i'm trying to do: #!/bin/bash opened=0 while [ "$opened" == "0" ]; do echo "Waiting jenkins to launch on 8080..." nc -vz localhost 8080 done echo "Jenkins launched" You can't set netcat to wait until some port is open, so you have to add part for waiting before next check is made. Try this: #!/bin/bash echo "Waiting jenkins to launch on 8080..." while ! nc -z localhost

如何检查某个端口是否开启的 3 种方法

半腔热情 提交于 2019-11-28 16:43:54
这是一个很重要的话题,不仅对 Linux 管理员而言,对于我们大家而言也非常有帮助。我的意思是说对于工作在 IT 基础设施行业的用户来说,了解这个话题也是非常有用的。他们需要在执行下一步操作前,检查 Linux 服务器上某个端口是否开启。 假如这个端口没有被开启,则他们会直接找 Linux 管理员去开启它。如果这个端口已经开启了,则我们需要和应用团队来商量下一步要做的事。 在本篇文章中,我们将向你展示如何检查某个端口是否开启的 3 种方法。 这个目标可以使用下面的 Linux 命令 来达成: nc:netcat 是一个简单的 Unix 工具,它使用 TCP 或 UDP 协议去读写网络连接间的数据。 nmap:(“Network Mapper”)是一个用于网络探索和安全审计的开源工具,被设计用来快速地扫描大规模网络。 telnet:被用来交互地通过 TELNET 协议与另一台主机通信。 如何使用 nc(netcat) 命令 来查看远程 Linux 系统中某个端口是否开启? nc 即 netcat。netcat 是一个简单的 Unix 工具,它使用 TCP 或 UDP 协议去读写网络连接间的数据。 它被设计成为一个可信赖的后端工具,可被直接使用或者简单地被其他程序或 脚本 调用。 与此同时,它也是一个富含功能的网络调试和探索工具,因为它可以创建你所需的几乎所有类型的连接