免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3475 | 回复: 1
打印 上一主题 下一主题

tnsping 脚本的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-11 14:24 |只看该作者 |倒序浏览
写个bash测试tnsping(加到crontab中),但是在脚本里执行的结果和在shell里执行的结果完全不一样
scripts
#!/bin/bash
oracle_home='/home/oracle'
oracle_base_home='/opt/oracle/product/10.2.0/db_1/bin'
my_date=`date +%Y-%m-%d_%H:%M:%S`
echo $my_date >> $oracle_home/tnspingtest.txt
$oracle_base_home/tnsping 172.17.1.8 >> $oracle_home/tnspingtest.txt
$oracle_base_home/tnsping 172.17.1.15 >> $oracle_home/tnspingtest.txt
echo '------------------------------------------------------------------' >> $oracle_home/tnspingtest.txt

脚本运行结果
2008-04-11_13:10:01

TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 11-APR-2008 13:10:01

Copyright (c) 1997, 2007, Oracle.  All rights reserved.

Message 3511 not found; No message file for product=network, facility=TNSMessage 3512 not found; No message file for product=network
, facility=TNSAttempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.(PORT=1521))(
ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.(PORT=1521)))
Message 3509 not found; No message file for product=network, facility=TNS

TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 11-APR-2008 13:10:01

Copyright (c) 1997, 2007, Oracle.  All rights reserved.

Message 3511 not found; No message file for product=network, facility=TNSMessage 3512 not found; No message file for product=network
, facility=TNSAttempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521)))
Message 3509 not found; No message file for product=network, facility=TNS

shell 执行结果
$ tnsping 172.17.1.8

TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 11-APR-2008 14:07:26

Copyright (c) 1997, 2007, Oracle.  All rights reserved.

Used parameter files:

Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.(PORT=1521)))
OK (30 msec)
$ tnsping 172.17.1.15

TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 11-APR-2008 14:07:52

Copyright (c) 1997, 2007, Oracle.  All rights reserved.

Used parameter files:

Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521)))
OK (10 msec)

清DX们看看,这到底是因为什么导致的?
我的想法是要在脚本中添加有关ORACLE的环境变量。

论坛徽章:
0
2 [报告]
发表于 2008-04-11 15:19 |只看该作者
在脚本开始的地方加
. .bash_profile
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP