Need help with script

for i in "/var/log/all/"
do
set -- $i
for j in "$i/sudo.
"
do
cat $j | /home/dariley/sudo-filter.pl
done
done

The result is the following error message:

./sudo-filter-invoker.sh: /bin/cat: arg list too long

I want the script to go through all the log files on this log server and find the sudo entries which are then piped into a perl script. Please help, what am I missing?

i think $j is getting a huge no of argument so its giving that error..
try using different logic

Hi,

i don't understand what you are using the two for loops for.
If you try to traverse down recursively a directory, find can
do this for you. If you use "while read" instead of for, you
can pass the filenames one by one. Take this as an example:

find /var/log/all -iname "sudo\.*" | while read file 
do 
  cat "$file" | /home/dariley/sudo-filters.pl
done

HTH Chris

Chris,

thank you for the suggestion but I'm afraid that didn't work so well.
It created about two thousand emails in two minutes :slight_smile:

The orginal statement that use to work when the filesystem was small:
#!/bin/sh
cat /var/log/all/*/sudo.* | \
/home/dariley/sudo-filter.pl

I can get this to work if I specify each serverlog in the subdirectory:

#!/bin/sh
cat /var/log/all/watership/watership.current | \
/home/dariley/sudo-filter.pl

but I want to make it so that as new server logs are added I don't have to edit the script.

Any suggestions?

Thanks.