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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
If then else loop not working findprakash UNIX for Dummies Questions & Answers 2 05-24-2008 09:43 PM
For loop not working...! :( bullz26 Shell Programming and Scripting 3 03-16-2008 03:28 AM
if loop is not working ranga27 Shell Programming and Scripting 3 09-16-2007 09:19 AM
for loop not working - syntax error at line 6: `end of file' unexpected debojyoty Shell Programming and Scripting 2 03-10-2006 12:45 PM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 08:09 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-06-2001
nitin's Avatar
Registered User
 

Join Date: Aug 2001
Location: Toronto, ON
Posts: 56
Loop not working

Apologize if this is doesn't come under this group. I have a small script to find out users who last logged in to check there mail. (Tru 64 4.0, Netscape mail 3.6)
----->
cat $1|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/ {s=$5;u[s]++;las=substr($1)} END {for (i in u) {print i,u[i],las}}'|sort>>/tmp/mailusage.list
<-----
It works when I run it with just one file (e.g script log20011107). But bombs out when I give command: script log*. It checks the first file only. I tried to put another for loop for the script, but no good. Any suggestions. TIA, Ciao,
Reply With Quote
Forum Sponsor
  #2  
Old 11-06-2001
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
You mention that you already tried looping it...
It didn't work when you did something like this?:

for each in `ls -1 log*`
do
cat $each|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/ {s=$5;u[s]++;las=substr($1)} END {for (i in u) {print i,u[i],las}}'|sort>>/tmp/mailusage.list
done

What happened when you tried that?
Reply With Quote
  #3  
Old 11-07-2001
nitin's Avatar
Registered User
 

Join Date: Aug 2001
Location: Toronto, ON
Posts: 56
LivinFree,
This what I just did, and it worked:
----
cd /netscape/logsdir
>/tmp/mailus.list
cat Maillogs*|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/{s=$5;u[s]++;las=substr($1,1,8)} END {for (i in u) {print
i,u[i],las}}'|sort>>/tmp/mailusage.list
join -a 1 -e NA -o 1.1 2.3 2.2 /tmp/users.list /tmp/mailusage.list>/tmp/totalusage.list
-----

Initially, I did this and used to give me errors: can not open log-date-file. It would list all the files saying it can't open them
for i in `ls /netscape/logsir/`
cat $1|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/{s=$5;u[s]++;las=substr($1,1,8)} END {for (i in u) {print
i,u[i],las}}'|sort>>/tmp/mailusage.list
join -a 1 -e NA -o 1.1 2.3 2.2 /tmp/users.list
---- What did I do wrong then? Well thanks, Ciao

Last edited by nitin; 11-08-2001 at 11:09 PM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0