Intersystems Cache SQL shell:如何将查询的输出假脱机到文件中?
我正在尝试在 UNIX 中创建一个脚本来查询缓存数据库。我可以获得输出,但如何将输出写入文件> 我使用了以下过程:
cache << EOF
DO \$SYSTEM.SQL.Shell()
SELECTMODE DISPLAY
SELECT * from .....
GO
EXIT
EOF
I am trying to create a script in UNIX to query the Cache database. I could get the output but how do I write the output to a file>
I used the following procedure:
cache << EOF
DO \$SYSTEM.SQL.Shell()
SELECTMODE DISPLAY
SELECT * from .....
GO
EXIT
EOF
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您将其用于报告/网页/等,我会查看 Intersystems 为 Perl、Python、Ruby 等提供的内置模块。这些应该为您提供更清晰的数据库界面。
也就是说,我出于监控目的进行了一些外部调用,但由于我试图从数据库(通常是内部)获取内容,因此不使用语言 API。在这些情况下我使用 Perl。我使用 Perl 是因为这样做我需要解析菜单和其他我不想要的东西(通过 API 是无法得到的)。以下是查看缓存中存在的所有用户的简单示例。
查看以下有关 Perl 和 Python API 的链接
http://docs.intersystems.com/cache20102 /csp/docbook/DocBook.UI.Page.cls?KEY=GBPL
和
http://docs.intersystems.com/cache20102 /csp/docbook/DocBook.UI.Page.cls?KEY=GBPY
If you are using this for reports/webpages/etc I would look at the built in modules that Intersystems provides for Perl, Python, Ruby, etc. These should give you a cleaner interface into the database.
That said, I do some external calls for monitoring purposes that don't use the language API because of what I am trying to get from the database (usually internals). In those cases I use Perl. I use Perl to because doing it this way I need to parse out the menus and other things I don't want (which you won't get with the APIs). The following is a simple example looking at all the users that exist in Cache.
Check out the following links about the Perl and Python API
http://docs.intersystems.com/cache20102/csp/docbook/DocBook.UI.Page.cls?KEY=GBPL
and
http://docs.intersystems.com/cache20102/csp/docbook/DocBook.UI.Page.cls?KEY=GBPY
这有点 hackish,但以下应该可以工作:
您在 Caché 中输入的每个命令后面都跟有一个“\n”以指示行返回。然后将其通过管道传输到新会话,并将其输出写入文件。
It's a bit hackish, but the following should work:
Each command you would enter in Caché is followed by a "\n" to indicate a line return. That is then piped into a new session and its output is written to the file.