命令提示符下远程服务器的输出
我可以使用 telnet 命令连接到远程 redis 并获取“mytest”键的值。以下内容按预期工作。
[root@server shantanu]# telnet 10.10.10.100 6379
Trying 10.10.10.100...
Connected to 10.10.10.100 (10.10.10.100).
Escape character is '^]'.
get mytest
$14
this is first
但是如何在 shell 脚本中使用它呢? 我习惯使用以下方式连接到 mysql:
msyql -h10.10.10.100 -uroot -proot@123 -e"show databases"
Is a similar syntax available for redis?
I can connect to remote redis using the telnet command and get the value of "mytest" key. The following is working as expected.
[root@server shantanu]# telnet 10.10.10.100 6379
Trying 10.10.10.100...
Connected to 10.10.10.100 (10.10.10.100).
Escape character is '^]'.
get mytest
$14
this is first
But how do I use it in shell script?
I am used to connect to mysql using the following:
msyql -h10.10.10.100 -uroot -proot@123 -e"show databases"
Is a simialar syntax available for redis?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您也可以使用 redis 中包含的
redis-cli
You can alternatively use
redis-cli
, included in redis我不知道 telnet,但使用 ssh 你可以:
例如
I don't know telnet, but with ssh you can:
for example
我会使用像 wget 这样的工具,它旨在获取来自网站的内容,并且非常可配置和自动化。 甚至可以将
如果对话需要比这更复杂,我 telnet 与 expect 结合使用,它是为触发和响应对话而设计的。
I would use a tool like wget, which is designed to get content from websites, and is very configurable and automaetable. You might even be able to get away with
If the conversation needs to be more complex than that, I would use telnet in combination with expect, which is designed for trigger and response conversations.