View the Most Wanted LQ Wiki articles.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-10-2003, 07:57 AM   #1
LQ Newbie
Registered: Apr 2002
Location: 33619
Distribution: r5eadhat 7.2
Posts: 6

Rep: Reputation: 0
usin AWK in cron job to send dynamic ip via email

code is

5 30 *** ifconfig -a eth0 | awk ' /inet addr / { print $2 } ' | mail,

it emails but doesnt print the ip addy in the body of the email u have to look at the header to find ip
is there a solution am i missing some code
Old 12-10-2003, 08:51 AM   #2
LQ Newbie
Registered: Nov 2003
Distribution: Red Hat Linux
Posts: 7

Rep: Reputation: 0
try following (spaces are removed) --

/sbin/ifconfig -a eth0 | awk '/inet addr/ { print $2 } ' | mail,

it's sending mail and address is in the mail body not in headers.

first just see what this is printing:
/sbin/ifconfig -a eth0 | awk '/inet addr/ { print $2 } '
and then do mailing part

hope this helps
Old 12-10-2003, 09:10 AM   #3
LQ Newbie
Registered: Apr 2002
Location: 33619
Distribution: r5eadhat 7.2
Posts: 6

Original Poster
Rep: Reputation: 0

thanks works like a charm


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
cron job email results... ryedunn Linux - General 7 01-26-2005 11:27 PM
cron job to send file via ftp every 1 hour mcalizo Linux - Newbie 1 07-14-2004 04:50 AM
cron job that email a text file paynsr Linux - Newbie 1 03-29-2004 02:36 PM
Cron job , send email mikeshn Linux - General 1 09-21-2003 10:02 AM
Send Email + Txt Attachment Using Cron Job beringer Linux - Newbie 3 01-31-2003 11:23 AM

All times are GMT -5. The time now is 05:03 AM.

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