The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing the values to the secondary script when it invoked by primary script venu_eie UNIX for Advanced & Expert Users 2 07-03-2008 08:10 AM
Passing the values to the secondary script when it invoked by primary script venu_eie Shell Programming and Scripting 1 07-03-2008 07:16 AM
create a shell script that calls another script and and an awk script magikminox Shell Programming and Scripting 0 06-26-2008 03:50 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 04:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-04-2008
a310318 a310318 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 2
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?
  #2 (permalink)  
Old 12-04-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,423
i think $j is getting a huge no of argument so its giving that error..
try using different logic
  #3 (permalink)  
Old 12-05-2008
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
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:


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

HTH Chris
  #4 (permalink)  
Old 12-05-2008
a310318 a310318 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 2
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

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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0