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 > 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
Yellow Book assistance needed FL1 UNIX for Dummies Questions & Answers 2 11-15-2007 04:04 PM
Script Needed Urgent in shell or PERL!!!!!!!!!!!!!!!!!!!! aajan Shell Programming and Scripting 1 10-24-2007 04:28 AM
Perl script assistance; paste word into external command bru Shell Programming and Scripting 10 02-23-2007 04:04 AM
Assistance needed. 12yearold UNIX for Dummies Questions & Answers 4 07-07-2006 03:26 AM
NFS mount assistance needed... Heron UNIX for Dummies Questions & Answers 2 03-21-2005 04:31 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-17-2009
SkySmart SkySmart is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 50
Assistance needed with perl script

Ok, theres a log file containing the below. Lets call the logfile log_fantastic:

2009/03/16 21:42:45 USER: tonnabo - MAC: 0014BF2D385A - STATUS_ID: 30 - STATE: ERROR
2009/03/16 21:42:45 USER: tonnabo - MAC: 001310AC120D - STATUS_ID: 15 - STATE: OK
2009/03/16 21:42:45 USER: tonnabo - MAC: 001DD9277095 - STATUS_ID: 20 - STATE: ERROR


I want to write a perl script that will read the contents of log_fantastic and output only the lines that does not have a status_id of 10?

the below is what i've done. not sure if this is correct:


use Data:: Dumper;

main();


sub main {
my @results;
my $headers = "user,
mac address,
status_id";

my (@log_info, @dircontents);


open (LOG, "</home/jhenson/log_fantastic");
@log_info = <LOG>;
close (LOG);

print Dumper("testing");
foreach my $content (@log_info) {
chomp($content);
my $line = substr ($content, -2);
print Dumper($line);
if ($line eq "OK") {
push @dircontents, $content;
}
}


#push @alarm_info, uc $headers;

print Dumper(@dircontents);

}
 

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 02:43 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