【问题标题】:Shell script to access sqlplus访问 sqlplus 的 Shell 脚本
【发布时间】:2010-12-22 23:51:02
【问题描述】:

任何人都可以帮助我将 shell 脚本连接到访问 sqlplus 。在 sqlplus 中,我需要运行一个 sql 脚本并将结果邮寄回一个邮件 ID。

例子

ls dir ----> has  abc.sql

我去sqlplus并通过==> **sqlplus username/password@instance @abc**运行查询

我想将结果邮寄到 xyz@enterprise.com

【问题讨论】:

    标签: bash shell sqlplus


    【解决方案1】:

    你应该可以做到:

    sqlplus username/password@instance @abc | mail -s "Email Subject" xyz@enterprise.com
    

    【讨论】:

    • 感谢您的回复。但是当我尝试上述行时,系统什么也没做。然后我不得不取消 ^Z[1] + Stopped (SIGTSTP) sqlplus username/password@instance @abc | mail -s "电子邮件主题" xyz@enterprise.com
    • @misguided:如果你自己执行sqlplus 命令,你会输出到屏幕上吗?如果您使用echo "hello" | mail -s "test message" xyz@enterprize.com,您会收到那封电子邮件吗?
    【解决方案2】:

    你应该将 sqlplus 的输出重定向到一个文件 然后使用 mailx 将其发送到指定的电子邮件 ID。

    【讨论】:

    • 不需要文件,直接通过管道到mailx
    猜你喜欢
    • 2010-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    相关资源
    最近更新 更多