Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 我可以grep telnet命令输出吗?_Linux_Telnet - Fatal编程技术网

Linux 我可以grep telnet命令输出吗?

Linux 我可以grep telnet命令输出吗?,linux,telnet,Linux,Telnet,我有一个telnet命令,它可以打印数百行输出,我可以grep输出吗?使用“script”命令。如果在运行telnet之前运行“脚本”,则写入终端的所有文本也会写入/file/path/filename。您必须执行“退出”或Ctrl-D才能真正写入文件,或者您可以对文件进行检查 最后,使用filename | grep“search text”对文件进行grep /file/path/filename是要存储telnet输出的路径 使用脚本命令 script /tmp/myscript.txt

我有一个telnet命令,它可以打印数百行输出,我可以grep输出吗?

使用“script”命令。如果在运行telnet之前运行“脚本”,则写入终端的所有文本也会写入/file/path/filename。您必须执行“退出”或Ctrl-D才能真正写入文件,或者您可以对文件进行检查

最后,使用filename | grep“search text”对文件进行grep

/file/path/filename是要存储telnet输出的路径

使用脚本命令

script /tmp/myscript.txt
然后,您在终端中发出的所有命令和输出都将进入该文件。 完成后使用ctrl+D,这将写入文件

对这个文件进行grep

cat /tmp/myscript.txt | grep "textToSearch"

使用
tee
命令将内容重定向到文件:

telnet google.com 80 | tee outfile

然后将文件grep

从网络连接grep输出,您可以使用Bash shell而不是
telnet
,例如:

exec {stream}<>/dev/tcp/example.com/80
printf "GET / HTTP/1.1\nHost: example.com\nConnection: close\n\n" >&${stream}
grep Example <&${stream}
exec{stream}/dev/tcp/example.com/80
printf“GET/HTTP/1.1\nHost:example.com\n连接:close\n\n”>&${stream}

grep示例/file/path/filename在哪里?您必须设置它。。您希望输出到哪里?在Windows中是否有同样的方法?谢谢。有没有办法从Perl脚本中实现这一点?