python - 无法使用 nc (netcat) 传输文件
问题描述
所以我有一个python脚本,它试图在两台机器之间通过nc传输一个大文件(1G)。这是为发件人启动进程的代码:
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
在哪里
command = nc -w 10 -4 *ip* *port* < file
这对于接收者:
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
command = nc -l -4 *port* > file
该文件传输损坏,并且比发送的文件小得多。
有趣的是,当我在接收端使用“-d”(从标准输入分离)标志时,它起作用了。但是现在我切换了机器,它的 nc 版本没有与 stdin 标志分离。此外,当我将 stdin = subprocess.PIPE 添加到 Popen 函数的参数时,它解决了以前机器上的问题,但没有解决这个问题。有什么建议么?
解决方案
推荐阅读
- python - 使用 NumPy 进行快速插值
- javascript - 如何从 svg 访问 html 对象标记中的 javascript 函数
- javascript - 在 React 中创建私有路由时遇到三元运算符的问题
- python - 使用 open_mfdataset 打开选定的文件
- ios - 在 IOS 中发送通知是否总是必须获得许可?
- javascript - 在同一页面上使用多个不同的编辑器“CKEDITOR5”
- python - 遍历文本文件中的行并解析匹配信息 Python
- r - 使用 knitr 和 knitExtra 编织时找不到 kable_input
- javascript - 在 chart.js 更改工具提示标题?
- sql - 从用户获取一些输入并使用实体框架插入多个表