The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how would you know your server was rebooted 3 times or 5 times kenshinhimura AIX 3 01-16-2009 09:52 AM
Delete repeated nos in a file gini UNIX for Dummies Questions & Answers 2 09-02-2008 03:07 PM
matching repeated character robsonde Shell Programming and Scripting 5 12-13-2007 05:43 PM
Get rid of repeated entries. jijibabawu Shell Programming and Scripting 2 10-03-2005 10:17 PM
Repeated printF causes annoyance with do C|[anti-trust] High Level Programming 8 04-26-2005 02:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-06-2009
lichento lichento is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 1
how many times does this repeated sequence exist

need a script to determine daily how many times does the below repeated sequence exist in a log file, and if it shows failure to connect in the same file
200 PORT Command successful.
150 Opening BINARY mode data connection for rgr016.daily.0305.
226 Transfer complete.
local: rgr016.daily.0306 remote: rgr016.daily.0306

also grep for "Not connected"

(trying to confirm consistent daily number of expected transfers, & will want to use this total against list of expected outputted files on another /dir

Thanks!

log has been set to only keep one day's worth of transfers and will no longer append
  #2 (permalink)  
Old 03-07-2009
Shahul's Avatar
Shahul Shahul is offline
Registered User
  
 

Join Date: Aug 2008
Location: India
Posts: 175
Hi,

do "man grep"

Thanks
Sha
  #3 (permalink)  
Old 03-07-2009
ldapswandog ldapswandog is offline
Registered User
  
 

Join Date: Feb 2009
Location: Charlotte, NC
Posts: 101
echo -ne "Port:\t";grep -c 200 $file;echo -ne "Open:\t";grep -c 150 $file;echo -ne "Transfer:\t";grep -c 226 $file;echo -ne "Failed:\t";grep -ci "not connected" $file
  #4 (permalink)  
Old 03-07-2009
ldapswandog ldapswandog is offline
Registered User
  
 

Join Date: Feb 2009
Location: Charlotte, NC
Posts: 101
A better way using perl
=========================================
#!/usr/bin/perl -w

$PORT=0;
$OPEN=0;
$TRANS=0;
$FAIL=0;

unless (open(INPUT, "<test5.txt")) {
die ("cannot open input, check permissions\n");
}
unless (open(OUTPUT, ">output.txt")) {
die ("cannot open output, check permissions\n");
}
while ($line = <INPUT>) {
if ($line =~ /200/) {
$PORT++;
}
elsif ($line =~ /150/) {
$OPEN++;
}
elsif ($line =~ /226/) {
$TRANS++;
}
elsif ($line =~ /not connected/i) {
$FAIL++;
}
}
print OUTPUT "PORT: $PORT\n";
print OUTPUT "OPEN: $OPEN\n";
print OUTPUT "TRANS: $TRANS\n";
print OUTPUT "FAIL: $FAIL\n";

close (INPUT);
close (OUTPUT);
Sponsored Links
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 10:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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