telnet redis bash 脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19515962/
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:22:39  来源:igfitidea点击:

telnet redis bash script

bashredistelnet

提问by Matt

How can I extract the output from a telnet command on a remote redis-server in a bash script.

如何在 bash 脚本中从远程 redis 服务器上的 telnet 命令中提取输出。

I would do:

我会做:

telnet remote-redis-ip 6379 
LRANGE mylist 0 -1

And save the result in a variable. How can I reach this goal under a bash script?

并将结果保存在变量中。我怎样才能在 bash 脚本下达到这个目标?

Thanks,

谢谢,

回答by Chair

try this

尝试这个

RET=`telnet remote-redis-ip 6379 << EOF
LRANGE mylist 0 -1
EOF`

echo $RET

and I think using expect automating telnet session using bash scriptspost by fedorqui will be better

我认为使用fedorqui发布的bash脚本使用expect自动化telnet会话会更好