使用nc写入多个文件-如何? [英] Use nc to write multiple files - how?

查看:264
本文介绍了使用nc写入多个文件-如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将nc用作简单的TCP/IP服务器.到目前为止,我使用以下命令来运行它:

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.

基本上,如果跳过-k开关,我会得到这个信息,但是一旦第一个连接断开,nc就会关闭.

Basically I get this if I skip the -k switch, but then nc shuts down as soon as the first connection is gone.

如何保持nc运行,但为每个传入请求使用单独的文件? (或者,如果不可能的话,是否可以使用其他* nix工具来做到这一点?)

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 this?)

请注意,我不是要重启nc,但是我希望所有这些都在一个正在运行的实例中完成.

Please note that I do not want to restart nc, but I want it all with a single running instance.

PS:我知道SO不允许寻找工具的问题,但是对我来说,这只是万一,如果nc不能自己做到这一点,那将是一个后备.因此,对不起括号中的部分……

PS: I know that SO doesn't allow questions on finding tools, but for me this is only the fallback in case nc isn't able to do that by itself. So, sorry for the part in parentheses…

推荐答案

在接收方:

$ nc -p 3000 -l | tar -x

在发送者上:

$ tar -c * | nc <ip_address> 3000

这篇关于使用nc写入多个文件-如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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