如何将tcp数据从netcat放入变量? [英] how to put tcp data from netcat to variables?

查看:67
本文介绍了如何将tcp数据从netcat放入变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用通常的 nc-lk< port> 命令设置了服务器.

I have set up a server with the usual nc - lk <port> command.

我的客户端以xxx,yyy的形式将tcp数据发送到服务器套接字,这是数字.

My client sends tcp data to the server socket in the form of xxx,yyy which are numbers.

我希望每次客户端连接时,xxx和yyy的值都将存储在变量中,以便以后使用.

I want every time the client connects that the values of xxx and yyy would be stored in variables in order to use them later.

据我了解,我必须使用管道,但是我不确定该怎么做.

From what I understood I must work with pipes, but I am not sure how to do this.

推荐答案

您有两个选择:

  1. 将输出内容放置到文件中以供以后阅读
  2. 阅读每一行并实时进行操作:

例如:

nc -lk 8889 | while IFS=, read -a p
do echo ${p[1]} ${p[0]}
done

这篇关于如何将tcp数据从netcat放入变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆