当前位置: 技术问答>linux和unix
Shell Script 发生 "arg list too long" 的问题,求救!
来源: 互联网 发布时间:2016-05-28
本文导语: 今日碰到一个问题, 当运行以下代码时, 出现"arg list too long"的报错提示。 应该是因为文件列表太长的缘故 当文件数在15000,甚至20000个的时候,运行一切都正常。 但是在29000个的时候就报这个错了。 求:有没有...
今日碰到一个问题,
当运行以下代码时,
出现"arg list too long"的报错提示。
应该是因为文件列表太长的缘故
当文件数在15000,甚至20000个的时候,运行一切都正常。
但是在29000个的时候就报这个错了。
求:有没有其他更好的变通写法?拜谢!
cd $MMOUT
ls -l RDW* |
cut -c55-91 | # Cut the file name from the 'ls -l' record
sort |
cat > /tmp/POS_files_$MYRANDOM
报错信息如下:
/u03/oracle/batch/rms/oracle/proc/bin/batch_resa2rdw.ksh[71]: /usr/bin/ls: arg list too long
/u03/oracle/batch/rms/oracle/proc/bin/batch_resa2rdw.ksh[81]: /usr/bin/tar: arg list too long
详细源文件请见如下:
------------------------------
DXBRMSDB/orarms # cat batch_resa2rdw.ksh
#!/usr/bin/ksh
# Set the Retek Environment
#
environment=rms
export environment
. $AW_HOME/RETEK/exec/RETEK_ENVAR
# This script will do the following:
#
# Detect all the RESA RDW file to be processed and request the
# resa2rdw module to process them. It will then wait for them to leave the
# backlog queue of AppWorx (ie be processed)
#
#
# Clear the RDW concatonated files before we start
#
rm -f $MMOUT/RDW+_COMPLETE.DAT
#
# Clear all the RDW files from the out directory, this process will generate
# all the files for today
#
#rm -f $MMOUT/RDW*
MYRANDOM=$RANDOM # A random number to insure file names are unique.
export MYRANDOM
#
# The following command issues an ls command and gets a file that contains
# each file that begins with RDW within the $MMOUT directory
#
cd $MMOUT
ls -l RDW* |
cut -c55-91 | # Cut the file name from the 'ls -l' record
sort |
cat > /tmp/POS_files_$MYRANDOM
#
# For each file found above then request the RESA2RDW module to execute within
# AppWorx
#
while read pos_file_name; do # Read the file names which will be uploaded
echo $MMOUT/$pos_file_name
# awrun -m RESA2RDW -u sqloper -z s0pass -arg $MMOUT/$pos_file_name $DWIDATA/$pos_file_name rms a >> /tmp/tb.out
/usr/bin/perl $MMHOME/oracle/lib/src/resa2rdw $MMOUT/$pos_file_name $DWIDATA/$pos_file_name
done
当运行以下代码时,
出现"arg list too long"的报错提示。
应该是因为文件列表太长的缘故
当文件数在15000,甚至20000个的时候,运行一切都正常。
但是在29000个的时候就报这个错了。
求:有没有其他更好的变通写法?拜谢!
cd $MMOUT
ls -l RDW* |
cut -c55-91 | # Cut the file name from the 'ls -l' record
sort |
cat > /tmp/POS_files_$MYRANDOM
报错信息如下:
/u03/oracle/batch/rms/oracle/proc/bin/batch_resa2rdw.ksh[71]: /usr/bin/ls: arg list too long
/u03/oracle/batch/rms/oracle/proc/bin/batch_resa2rdw.ksh[81]: /usr/bin/tar: arg list too long
详细源文件请见如下:
------------------------------
DXBRMSDB/orarms # cat batch_resa2rdw.ksh
#!/usr/bin/ksh
# Set the Retek Environment
#
environment=rms
export environment
. $AW_HOME/RETEK/exec/RETEK_ENVAR
# This script will do the following:
#
# Detect all the RESA RDW file to be processed and request the
# resa2rdw module to process them. It will then wait for them to leave the
# backlog queue of AppWorx (ie be processed)
#
#
# Clear the RDW concatonated files before we start
#
rm -f $MMOUT/RDW+_COMPLETE.DAT
#
# Clear all the RDW files from the out directory, this process will generate
# all the files for today
#
#rm -f $MMOUT/RDW*
MYRANDOM=$RANDOM # A random number to insure file names are unique.
export MYRANDOM
#
# The following command issues an ls command and gets a file that contains
# each file that begins with RDW within the $MMOUT directory
#
cd $MMOUT
ls -l RDW* |
cut -c55-91 | # Cut the file name from the 'ls -l' record
sort |
cat > /tmp/POS_files_$MYRANDOM
#
# For each file found above then request the RESA2RDW module to execute within
# AppWorx
#
while read pos_file_name; do # Read the file names which will be uploaded
echo $MMOUT/$pos_file_name
# awrun -m RESA2RDW -u sqloper -z s0pass -arg $MMOUT/$pos_file_name $DWIDATA/$pos_file_name rms a >> /tmp/tb.out
/usr/bin/perl $MMHOME/oracle/lib/src/resa2rdw $MMOUT/$pos_file_name $DWIDATA/$pos_file_name
done