LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-22-2009, 07:23 PM   #1
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Rep: Reputation: Disabled
bash script in background - awk and send email


I'm trying to write a script that will always be running in the background
and awk for the first column in the output; if the output don't match with
my predefined output, it will send out an email.

The current output I'm getting is

Quote:

00:30:96:16:24:23 -> 00:1b:cf:12:a7:21 192.168.25.1 -> 192.168.25.25
I would like to awk the "00:30:96:16:24:23" and match against my pre-defined "00:30:96:16:24:23"


Here's my script

Code:
#!/bin/bash
tshark -i eth0 -n port 68 -R 'bootp.type == 2' -o column.format:'"Source MAC","%hs","Destination MAC","%hd","Source","%s","Destination","%d"'
Thanks for any help.

Last edited by noir911; 03-22-2009 at 07:24 PM.
 
Old 03-22-2009, 07:28 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,696
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
to get a column in awk... such as column 1, use $1.
 
Old 03-22-2009, 08:25 PM   #3
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ghostdog74 View Post
to get a column in awk... such as column 1, use $1.
I tried

Code:
#!/bin/bash
tshark -i eth0 -n port 68 -R 'bootp.type == 2' -o column.format:'"Source MAC","%hs","Destination MAC","%hd","Source","%s","Destination","%d"' | awk {'print $1'}
But I get no output.
 
Old 03-22-2009, 08:27 PM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,696
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
hint at awk: you got your single quotes wrong.
 
Old 03-22-2009, 09:46 PM   #5
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Original Poster
Rep: Reputation: Disabled
I have rewritten the script but it only prints "foo" when I type ^c.

Code:
#!/bin/bash
tshark -i eth0 -n port 68 -R 'bootp.type == 2' -o column.format:'"Source MAC","%hs"'
MAC1="00:b6:f5:91:12:46"

ARG1=$1
if [ "$ARG1" != "$MAC1" ]; then
 echo "foo" 
fi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to send email when internet cap is reached aeby Linux - Server 7 08-22-2007 07:46 AM
How to send email using bash? mesh2005 Programming 4 03-03-2007 09:48 AM
Bash script hangs upon starting another script in the background masea2 Linux - Software 4 11-13-2006 05:18 AM
Write a script to send an email from bash kpelczar Linux - Software 5 02-09-2005 04:19 PM
usin AWK in cron job to send dynamic ip via email digihlp Programming 2 12-10-2003 08:10 AM


All times are GMT -5. The time now is 07:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration