unix ksh脚本中的分段错误
在刚刚安装IBMInfoSphereVersion8的新unix服务器上运行ksh脚本时,我遇到了一个SIGSEGV错误。 当unix脚本更新配置文件中的提取日期时间时,我遇到了错误。该脚本由Datastage序列调用 脚本因以下问题而中止: “程序”//bin/sh“已终止。[SIGSEGV]分段冲突” 对该问题的web搜索表明,该问题是由对内存的无效引用引起的 下面提到的是执行脚本的命令unix ksh脚本中的分段错误,unix,ksh,Unix,Ksh,在刚刚安装IBMInfoSphereVersion8的新unix服务器上运行ksh脚本时,我遇到了一个SIGSEGV错误。 当unix脚本更新配置文件中的提取日期时间时,我遇到了错误。该脚本由Datastage序列调用 脚本因以下问题而中止: “程序”//bin/sh“已终止。[SIGSEGV]分段冲突” 对该问题的web搜索表明,该问题是由对内存的无效引用引起的 下面提到的是执行脚本的命令 "ksh shUpdate_Config.sh MEARS MSDS_MP_ATTRIBUTES_BS_
"ksh shUpdate_Config.sh MEARS MSDS_MP_ATTRIBUTES_BS_VW /data/projects/scver_etl/EXTRACTS_pub/configurationfiles/MEARS.MSDS_MP_ATTRIBUTES_BS_VW.Lastupdseqno.dat /data/projects/scver_etl/EXTRACTS_pub/configurationfiles/ '2012-08-08 12:35:24'"
下面是脚本的内容-
#!/bin/ksh
#########################################################################
#Script Name:-shUpdate_Config.sh
#
#Script Description:- The script updates the STATUS_TABLE with the Extraction Date time and updates the sequence number by 1.
#
#Created By:- Vineet
#
#Job History:-
#
#Sl No Version Modification Date Modified by Modification Desc
#01. Initial 11/04/2012 Vineet Initial Version
#########################################################################################################################################
if [ $# -ne 5 ]
then
print "Incorrect number of parameters passed, Quiting ..."
exit 1
fi
# Enter the Source Id From the user
srcid=$1
# Enter the source table name by user
tabnme=$2
# Enter the Status File Name from User
filename=$3
#Enter the Temp file Path from User
file_path=$4
#Enter the Server time to be updated
Server_datetime=$5
if [ ! -f $filename ]
then
print "Configuration File not present at the required path, Quiting ..."
exit 1
fi
grep $srcid $filename >> /dev/null
if [ $? -ne 0 ]
then
print "Source system name not found in configuration file, Quiting ..."
exit 1
fi
grep $tabnme $filename >> /dev/null
if [ $? -ne 0 ]
then
print "Source view name not found in configuration file, Quiting ..."
exit 1
fi
while [ 1 ]
do
if [ -f $filename.lock ]
then
sleep 60
else
break
fi
done
touch $filename.lock
DT=`echo $Server_datetime|cut -c1-10`
TM=`echo $Server_datetime|cut -c12-19`
awk '{FS="|";OFS="|"};{a=$3;b=$4;if ($1=="'$srcid'"&& $2=="'$tabnme'") {$3=a+1;$4="'$DT'"" ""'$TM'"} else{}{print $0}}' $filename > $file_path$srcid.$tabnme.tmp
if [ $? -ne 0 ]
then
print "Process failed, Quiting ..."
/bin/rm $filename.lock
exit 1
fi
#fi
mv $file_path$srcid.$tabnme.tmp $filename
if [ $? -ne 0 ]
then
print "Process failed, Quiting ..."
/bin/rm $filename.lock
exit 1
fi
/bin/rm $filename.lock
if [ $? -ne 0 ]
then
print "Process failed, Quiting ..."
exit 1
fi
exit 0
以下是我们正在尝试更新的文件(MEARS MSDS\u MP\u EVENTS\u BS\u VW Lastupdseqno)的内容-
Source_sys_name|Source_tbl_name|Seq_No|Extraction_date|Extraction_Mode
MEARS|MSDS_MP_EVENTS_BS_VW|37|2012-08-08 11:51:19|D
请帮忙
该脚本由Datastage序列调用。
脚本因以下问题而中止:
"Program "/bin/sh" terminated. [SIGSEGV] segmentation violation".
从上面,我了解到脚本是从不同的程序调用的
根据调用字符串的定义:“ksh shUpdate\u Config.sh…”
其工作方式是由unixsystem(string)
library调用执行您定义的任何外部命令(您称之为Datastage序列)。这反过来又调用:
/bin/sh -c <string>
/bin/sh-c
显然,该调用有问题,因为崩溃的不是ksh
,而是/bin/sh
首先要检查的是命令行“ksh shUpdate_Config.sh…”对于初学者,您的定义是否包含双引号“”,或者您是否为本例添加了双引号?当您运行/bin/ksh时,它是否真的说“/bin/sh terminated”?它在哪里(ksh-x脚本的最后几行显示了什么内容)?