【发布时间】: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
【问题讨论】:
任何人都可以帮助我将 shell 脚本连接到访问 sqlplus 。在 sqlplus 中,我需要运行一个 sql 脚本并将结果邮寄回一个邮件 ID。
例子
ls dir ----> has abc.sql
我去sqlplus并通过==> **sqlplus username/password@instance @abc**运行查询
我想将结果邮寄到 xyz@enterprise.com
【问题讨论】:
你应该可以做到:
sqlplus username/password@instance @abc | mail -s "Email Subject" xyz@enterprise.com
【讨论】:
sqlplus 命令,你会输出到屏幕上吗?如果您使用echo "hello" | mail -s "test message" xyz@enterprize.com,您会收到那封电子邮件吗?
你应该将 sqlplus 的输出重定向到一个文件 然后使用 mailx 将其发送到指定的电子邮件 ID。
【讨论】: