Sqlplus命令无法通过plink工作

时间:2014-06-24 11:54:54

标签: shell sqlplus putty

我有一个shell脚本,我使用sqlplus命令从数据库中获取数据(在Linux上安装)。相同的脚本在Linux环境中运行良好。当我通过使用下面的批处理文件在窗口环境上执行脚本时。

set ORACLE_TERM=xterm
set ORACLE_BASE=/home/pwcadm/app/pwcadm
set ORACLE_HOME=/home/pwcadm/app/pwcadm/product/11.2.0/client_1
set ORACLE_HOSTNAME=kyora02.kymab.local
set ORACLE_SID=orcl
set ORA_NLS11=$ORACLE_HOME/nls/data
set LANG=en_US.UTF-8
set PATH=/opt/CollabNet_Subversion/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/home/pwcadm/app/pwcadm/product/11.2.0/client_1/bin:/home/pwcadm/app/pwcadm/product/11.2.0/client_1/bin:/home/pwcadm/app/pwcadm/product/11.2.0/client_1/lib/site_perl/5.8.3/i686-linux-thread-multi:/home/pwcadm/app/pwcadm/product/11.2.0/client_1/perl/lib/5.10.0/x86_64-linux-thread-multi:/home/pwcadm/app/pwcadm/product/11.2.0/client_1/perl/bin:/home/pwcadm/Informatica/PowerCenter9.1.0.3/server/bin
set LD_LIBRARY_PATH=/home/pwcadm/app/pwcadm/product/11.2.0/client_1/lib:/home/pwcadm/app/pwcadm/product/11.2.0/client_1/lib32:/home/pwcadm/Informatica/PowerCenter9.1.0.3/server/bin
cd C:\Program Files\PuTTY
plink csaadm@172.16.122.11 -pw csaadm /app/csa/REG_AUTOMATION/scripts/CHECK_GAN_INSERT.sh

批处理文件正在提示以下错误消息。即使我已经设置了所有路径。

C:\Program Files\PuTTY>plink csaadm@172.16.122.11 -pw csaadm /app/csa/REG_AUTOMA
TION/scripts/CHECK_GAN_INSERT.sh
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
FAIL
/app/csa/REG_AUTOMATION/scripts/CHECK_GAN_INSERT.sh: line 27: [: -ne: unary oper
ator expected

CHECK_GAN_INSERT.sh

ACCOUNT_GLOBAL_COUNT=$(echo "
        set heading off
        set feedback off
        set verify off
        set trimspool on
        set trimout off
        set pagesize 0
        set space 0
        whenever sqlerror exit 2;
SELECT COUNT(*) FROM ACCOUNT_GLOBAL WHERE NAME='test';
"|/home/pwcadm/app/pwcadm/product/11.2.0/client_1/bin/sqlplus -S ${DB_USERNAME}/${DB_PASSWORD}@${CONNECTING_STRING})

EROR_MSG=$(echo ${ACCOUNT_GLOBAL_COUNT} |grep ORA|wc -l)

if [ ${EROR_MSG} -ne 0 ]
then
        echo "${ACCOUNT_GLOBAL_COUNT}"
        exit;
fi

if [ ${ACCOUNT_GLOBAL_COUNT} -ne 0 ]
then
        echo "PASS"
else
        echo "FAIL"
fi

请帮忙。

1 个答案:

答案 0 :(得分:0)

我们没有足够的有关您的问题的信息,但我的猜测是:

  • 你必须设置ORACLE_HOME env。每次登录时(或将其添加到自动可执行脚本中),
  • 您还必须延长PATH(使用export PATH=$PATH:$ORACLE_HOME/bin),
  • 也可能需要启动Oracle实例。

检查这三点并在问题仍未解决时更新您的问题。