bash 通过在后台运行将 Telnet 输出捕获到文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19268832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 08:14:46  来源:igfitidea点击:

Capture Telnet output to a file by running in the background

linuxbashshell

提问by neo

I am having a linux powered board on which I wanted to capture the telnet output to a file. I tried doing it as shown below-

我有一个 linux 驱动的电路板,我想将 telnet 输出捕获到一个文件中。我尝试这样做,如下所示 -

telnet localhost xxxx >> /mnt/sd-xxx/log/file.txt &

as well as

telnet localhost xxxx | tee /mnt/sd-xxx/log/file.txt &

and

telnet localhost xxxx -f /mnt/sd-xxx/log/file.txt &

But it's unable to go in background in all of the above cases. I also tried to keep it in a script,but this also doesn't work and the program crashes. How can I capture the telnet output and redirect to a file by running it as a background process.

但在上述所有情况下都无法进入后台。我也尝试将它保存在脚本中,但这也不起作用并且程序崩溃了。如何捕获 telnet 输出并通过将其作为后台进程运行来重定向到文件。

Thanks in Advance.

提前致谢。

回答by Cole Tierney

Have you tried curl?

你试过卷曲吗?

curl telnet://localhost:xxxx >> /mnt/sd-xxx/log/file.txt &