usr/bin/ls: 0403-027 The parameter list is too long


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting usr/bin/ls: 0403-027 The parameter list is too long
# 1  
Old 06-25-2009
usr/bin/ls: 0403-027 The parameter list is too long

I ran this script in AIX 5L environment and getting an error
usr/bin/ls: 0403-027 The parameter list is too long
Our administrator had increased the maxium allowable size of the ARG/ENV list but it still doesn't work.
I have tested the command in red below in the unix prompt and it works just fine, but why it failed from the shell programming script. Please advice.


Code:
scpdir=/$ROOTDIR/scp/inbox/
cd $scpdir
pntcnt=`find . -name 'PNT.*' -type f | wc -l`
if [[ $pntcnt -gt 0 ]] then
for gfile in `ls -1 /$ROOTDIR/scp/inbox/PNT.2*`
 do
   gline=`sed '1q' $gfile`
   x=`echo "$gline" | awk '{ print substr( $0, 59, 1 ) }'`
   filename=`echo "$gfile" | awk '{ print substr( $0, 20, 28 ) }'`                            
   if [ "$x" -eq "0" -o "$x" -eq "1" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string1/$filename
   elif [ "$x" -eq "2" -o "$x" -eq "3" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string2/$filename	
   elif [ "$x" -eq "4" -o "$x" -eq "5" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string3/$filename
   elif [ "$x" -eq "6" -o "$x" -eq "7" ]; then 
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string4/$filename
   elif [ "$x" -eq "8" -o "$x" -eq "9" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string5/$filename
   fi
done
fi

Thank you for your help!
# 2  
Old 06-25-2009
From the error message, it seems the following line is failing:

for gfile in `ls -1 /$ROOTDIR/scp/inbox/PNT.2*`

Seems like the ls command is returning a huge list of files...

regards,
Arun.
# 3  
Old 06-25-2009
usr/bin/ls: 0403-027 The parameter list is too long

arunsoman80,

You're right, but when I changed the code below to

Code:
`find . -name 'PNT.*' -print | ls -1 /$ROOTDIR/scp/inbox'


Then I get an error message 0403-029 There is not enough memory available now. Please advice.
# 4  
Old 06-25-2009
You could probably write the list of all the files to be processed into a temporary file and then use that temp file for further processing...

Sample code (Not tested):
Code:
scpdir=/$ROOTDIR/scp/inbox/
cd $scpdir
pntcnt=`find . -name 'PNT.*' -type f | wc -l`
if [[ $pntcnt -gt 0 ]] then
ls -1 /$ROOTDIR/scp/inbox/PNT.2* > filesToProcess.tmp
while read gfile
do
   gline=`sed '1q' $gfile`
   x=`echo "$gline" | awk '{ print substr( $0, 59, 1 ) }'`
   filename=`echo "$gfile" | awk '{ print substr( $0, 20, 28 ) }'`                            
   if [ "$x" -eq "0" -o "$x" -eq "1" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string1/$filename
   elif [ "$x" -eq "2" -o "$x" -eq "3" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string2/$filename	
   elif [ "$x" -eq "4" -o "$x" -eq "5" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string3/$filename
   elif [ "$x" -eq "6" -o "$x" -eq "7" ]; then 
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string4/$filename
   elif [ "$x" -eq "8" -o "$x" -eq "9" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string5/$filename
   fi
done<filesToProcess.tmp

rm -f filesToProcess.tmp

fi

Hope this helps...

regards,
Arun.
# 5  
Old 06-25-2009
usr/bin/ls: 0403-027 The parameter list is too long

That works! Thank you for your help!

---------- Post updated at 01:10 PM ---------- Previous update was at 12:07 PM ----------

Arun,

While read gfile line code in read below. What is gfile? Is it a mistype of gline? Thanks


Code:
scpdir=/$ROOTDIR/scp/inbox/
cd $scpdir
pntcnt=`find . -name 'PNT.*' -type f | wc -l`
if [[ $pntcnt -gt 0 ]] then
ls -1 /$ROOTDIR/scp/inbox/PNT.2* > filesToProcess.tmp
while read gfile
do
   gline=`sed '1q' $gfile`
   x=`echo "$gline" | awk '{ print substr( $0, 59, 1 ) }'`
   filename=`echo "$gfile" | awk '{ print substr( $0, 20, 28 ) }'`                            
   if [ "$x" -eq "0" -o "$x" -eq "1" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string1/$filename
   elif [ "$x" -eq "2" -o "$x" -eq "3" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string2/$filename	
   elif [ "$x" -eq "4" -o "$x" -eq "5" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string3/$filename
   elif [ "$x" -eq "6" -o "$x" -eq "7" ]; then 
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string4/$filename
   elif [ "$x" -eq "8" -o "$x" -eq "9" ]; then
	mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string5/$filename
   fi
done<filesToProcess.tmp

rm -f filesToProcess.tmp

fi

# 6  
Old 06-25-2009
gfile is just a variable... I just used the same variables that you pasted in the actual piece of code...
for gfile in `ls -1 /$ROOTDIR/scp/inbox/PNT.2*`

Basically filesToProcess.tmp would be a temp file with the names of all the files that you want to rename/move... When its processed in the while loop, each file name is read into the variable gfile and then that variable is used down the line in the code...

Is it not working as expected?

regards,
Arun.
# 7  
Old 06-25-2009
usr/bin/ls: 0403-027 The parameter list is too long

Arun,

Thank you for your clarification. Because I can not use the line code
ls -1 /$ROOTDIR/scp/inbox/PNT.2* > filesToProcess.tmp
due to an error "0403-027 The parameter list is too long". Then I have to replace it with
find . -name "PNT.2*" -print | ls -1 /$ROOTDIR/scp/inbox/ > FilesToProcess.tmp.
In the end result, it moved all the PNT.* files from the current directory plus all the PNT files from sub-directories which it should not. Is there a way that I just move those PNT files from the current directory but not the sub-directories?
Thanks
Code:
scpdir=/$ROOTDIR/scp/inbox/
cd $scpdir
pntcnt=`find . -name "PNT.*" -print | wc -l`
if [[ $pntcnt -gt 0 ]] then
find . -name "PNT.2*" -print | ls -1 /$ROOTDIR/scp/inbox/ > FilesToProcess.tmp
while read gfile
 do
   gline=`sed '1q' $gfile`
   x=`echo "$gline" | awk '{ print substr( $0, 59, 1 ) }'`
   filename=`echo "$gfile" | awk '{ print substr( $0, 1, 28 ) }'`
   if [ "$x" -eq "0" -o "$x" -eq "1" ]; then
        mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string1/$filename
   elif [ "$x" -eq "2" -o "$x" -eq "3" ]; then
        mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string2/$filename
   elif [ "$x" -eq "4" -o "$x" -eq "5" ]; then
        mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string3/$filename
   elif [ "$x" -eq "6" -o "$x" -eq "7" ]; then
        mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string4/$filename
   elif [ "$x" -eq "8" -o "$x" -eq "9" ]; then
        mv /$ROOTDIR/scp/inbox/$filename /$ROOTDIR/scp/inbox/string5/$filename
   fi
done<FilesToProcess.tmp
rm -f FilesToProcess.tmp
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

0403-027 The parameter list is too long on AIX 5.3

Hi we are using AIX 5.3 64bit I have near about 79000 log file having naming convention like "IFTMBCSun Aug 14 07:45:00 PAKST 2011". This naming convention was created by a script error, now we need to rename these log file by removing extar spaces and (:) colon for that we wrote below script ... (4 Replies)
Discussion started by: lodhi1978
4 Replies

2. AIX

aix:ksh: /usr/bin/rm: 0403-027 The parameter list is too long.

Hi, I am getting the below error message When i am trying to delete the files from the directory.Could you please guide me? rm *.aud ksh: /usr/bin/rm: 0403-027 The parameter list is too long. and find /oracle/admin/testP/adump/*.aud -mtime +5 -exec rm {} \; ksh: /usr/bin/find:... (3 Replies)
Discussion started by: nokiae63
3 Replies

3. UNIX for Dummies Questions & Answers

UNIX: 0403-027 The parameter list is too long

Hello All, We have a batch job that clean old records. This run a script to back up file then delete. Unfortunately, this job been failing lately. This is the error we received. "/usr/bin/compress: 0403-027 The parameter list is too long." I am not sure if the job failed since its... (2 Replies)
Discussion started by: juieshenkei
2 Replies

4. Shell Programming and Scripting

/usr/bin/ls: 0403-027 the parameter list is too long.

Hi, I'm trying to list specific files and redirecting to a file ls aqp* > temp.lst but getting "/usr/bin/ls: 0403-027 the parameter list is too long." error. I just have 236 files in the directory. I tried "ls | grep 'aqp*' > temp.lst" too, but nothing was redirected. + grep aqp* +... (4 Replies)
Discussion started by: dateez
4 Replies

5. UNIX for Dummies Questions & Answers

0403-027 The parameter list is too long.

hi when i ran the following command rm *_F i got this error 0403-027 The parameter list is too long. It shd remove 5000(around) files pls help me on this. why its throwing this error how to rectify this error (5 Replies)
Discussion started by: romiljain
5 Replies

6. UNIX for Dummies Questions & Answers

ksh: /usr/bin/ls: arg list too long

I am using IBM AIX unix version 4.3.3.0. In a directory there are many files with different patterns. When I am trying to execute the command, ls -l with the file pattern, which have fewer files it gives the desired result. However when I am trying to execute the same command for file pattern,... (2 Replies)
Discussion started by: jitindrabappa
2 Replies

7. Shell Programming and Scripting

ksh: /bin/grep: arg list too long

when i run the command below in a directory which contains too many files i got the error: ksh: /bin/grep: arg list too long ls|grep AA*B* how can i handle this problem? (5 Replies)
Discussion started by: gfhgfnhhn
5 Replies

8. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies

9. UNIX for Dummies Questions & Answers

Grep 0403-027 The parameter list is too long.

Hi there I get this error message when I try to do a basic grep. Does anyone have any ideas what is wrong. Thanks 0403-027 The parameter list is too long. (1 Reply)
Discussion started by: japada
1 Replies
Login or Register to Ask a Question