如果 Intersystems Cache DB 专家能够解决这个问题,那就太好了:
我通过在 RHEL linux 上从 VI 编辑器手动编辑文件创建了一个脚本,并在 CACHE DB 上运行该文件,所有命令都成功运行。批处理脚本是:
#! /bin/ksh
. /apps/ins/.profile
cache <<-!END
do \$system.Security.Login("_SYSTEM","SYS")
do \$system.SQL.Shell()
select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator= '278/PLMN/000100'
select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator= '208/PLMN/002000'
select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator= '208/PLMN/000100'
select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator= '206/PLMN/001000'
exit
h
!END
成功的输出:
Node: sur-eir2, Instance: CACHEHA
INS>
INS>
SQL Command Line Shell
----------------------------------------------------
Enter q to quit, ? for help.
INS>>
1. select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator= '278/PLMN/000100'
Aggregate_1
0
1 Rows(s) Affected
---------------------------------------------------------------------------
INS>>
2. select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator= '208/PLMN/002000'
Aggregate_1
0
1 Rows(s) Affected
---------------------------------------------------------------------------
INS>>
3. select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator= '208/PLMN/000100'
Aggregate_1
0
1 Rows(s) Affected
---------------------------------------------------------------------------
INS>>
4. select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator= '206/PLMN/001000'
Aggregate_1
0
1 Rows(s) Affected
---------------------------------------------------------------------------
INS>>
INS>
现在,当我尝试通过另一个主脚本(回显命令)创建这样的脚本并运行它时,相同的命令失败并显示语法错误。我的主要脚本是:
==============From Here=========================
#! /bin/ksh
while read line
do
echo "select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator = '$line'"
done < plmn_list >> command_list ;
echo "#! /bin/ksh" >> get_count
echo ". /apps/ins/.profile" >> get_count
echo "cache <<-!END" >> get_count
echo "do \$system.SQL.Shell()" >> get_count
cat command_list >> get_count
echo "exit" >> get_count
echo "h" >> get_count
echo "!END" >> get_count
==================till here the get_count script is generated fine========
chmod u+rwx get_count
ksh ./get_count > query_result <-- query_result shows syntax errors
sed -n '/Aggregate_1/,+1p' query_result | grep -v "Aggregate_1" > count
paste plmn_list count > report
rm -f command_list get_count
内容get_count
:
#! /bin/ksh
. /apps/ins/.profile
cache <<-!END
do $system.SQL.Shell()
select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator = '278/PLMN/000100'
select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator = '208/PLMN/002000'
select count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator = '208/PLMN/000100'
exit
h
!END
所以那里的一切看起来都很好。然而query_result
节目显示:
Node: sur-eir2, Instance: CACHEHA
INS>
DO .SQL.Shell()
^
<SYNTAX>
INS>
SELECT count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator = '278/PLM
^
N/000100'
<SYNTAX>
INS>
SELECT count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator = '208/PLM
^
N/002000'
<SYNTAX>
INS>
SELECT count(*) from cdat_tb_ceir_blacklist_7 where cdat_c_originator = '208/PLM
^
N/000100'
<SYNTAX>
INS>
EXIT
^
<SYNTAX>
INS>
单独运行时的每个命令get_count
也可以正常工作。那么为什么会出现语法错误呢?