Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
send file via email ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
gopher2
n00b
n00b


Joined: 10 Oct 2005
Posts: 38

PostPosted: Sat Mar 28, 2009 3:26 pm    Post subject: send file via email ? Reply with quote

I have a program running like this

program --log file.log

i monitor the log file for events via

tail -f file.log | grep event

how can i have my self emailed of these particular events

something like?
tail -f file.log | grep event > sendmail me@email.com ?

thanks guys
Back to top
View user's profile Send private message
ecroy
n00b
n00b


Joined: 08 Nov 2002
Posts: 59

PostPosted: Sat Mar 28, 2009 4:36 pm    Post subject: Reply with quote

I don't think there is a solution as simple as that. You _might_ probably achieve it by doing some hackish trickery like:
Code:
while :; do tail -n1 -f file.log | grep -m1 "event" | sed "s/event/mailheader\nevent-description/" | sendmail your@email; done

but apart from being error-prone it is also very ugly. The proper solution would be to get your program log to your system-logger of choice and use its e-mail alert capability.
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Sat Mar 28, 2009 4:54 pm    Post subject: Reply with quote

you may want to take a look at net-analyzer/sec
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
doctork
Guru
Guru


Joined: 25 Apr 2004
Posts: 370
Location: Cleveland, OH

PostPosted: Sat Mar 28, 2009 5:56 pm    Post subject: Reply with quote

I've used things like this in the past:
Code:
tail -f file.log | grep event | mailx -s "An event message" target@somewhere.com

This assumes that there's some MTA on the system capable of sending mail (sendmail).

EDIT: I can't say I've used it with a tail -f. That will require a bit of work to terminate the file being sent by mailx. I'll leave that as an exercise for the reader :)
--
doc
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3943
Location: Hamburg

PostPosted: Sat Mar 28, 2009 6:20 pm    Post subject: Reply with quote

doctork wrote:
I've used things like this in the past:
Code:
tail -f file.log | grep event | mailx -s "An event message" target@somewhere.com

This assumes that there's some MTA on the system capable of sending mail (sendmail).

EDIT: I can't say I've used it with a tail -f. That will require a bit of work to terminate the file being sent by mailx. I'll leave that as an exercise for the reader :)
--
doc
I'd bet that no mail is send as long as the tail command is running.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum