Shell:从远程主机获取数据并执行其他一些命令
我需要创建一个 shell 脚本来执行此操作:
- ssh 到另一个远程主机
- 在该主机上使用 sqlplus 并使用 spool 命令将数据从 oracle db 获取到文件中
- 将文件从该主机传输到我的主机
- 执行另一个 shell 脚本来处理数据文件
我已经完成了第 4 步 shell 脚本。现在我必须一一完成这4个步骤。我想创建一个脚本并完成所有这些操作。这可能吗?如何将数据从一台主机传输到我的主机?
我想也许db文件不是必需的。
注意:我必须 ssh 到另一台主机才能使用 sqlplus。它是唯一一台有权限访问数据库的主机。
I need to create a shell script to do this:
- ssh to another remote host
- use sqlplus on that host and spool command to get the data from oracle db into a file
- transfer the file from that host to my host
- excute another shell script to process the data file
I have finished the 4th step shell script. Now I have to do this 4 steps one by one. I want to create a script and do them all. Is that possible? How to transfer the data from one host to my host?
I think maybe the db file is not necessary.
Note: I have to ssh to another host to use sqlplus. It is the only one host which have the permission to access database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或
或,合而为一:
Or
Or, all in one:
好吧,格伦几乎总结了一切。
为了让您的生活更轻松,您可能还需要考虑设置无密码 ssh。与此相关的安全风险稍高,但在许多情况下风险可以忽略不计。
这是一个很好的教程的链接。这是一个基于 debian 的教程,但给出的命令在大多数主要 Linux 发行版上应该同样有效。
Well Glenn pretty much summed it all up.
In order to make your life easier, you may want to also consider setting up passwordless ssh. There is a slightly higher security risk associated with this, but in many cases the risk is negligible.
Here is a link to a good tutorial. It is a debian based tutorial, but the commands given should work the same on most major linux distros.