LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-05-2009, 10:06 AM   #1
Knucklehead00
LQ Newbie
 
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
Grep Recursive Search Results Send To E-mail or Log?


Hey all.

I am still working my around with Linux commands.

I was able to put together some code that found the occurence of a text phrase. The output came back perfect.

Now, I need to run the command again and either have it send the results to my e-mail or to a log file that I can download.

Here is the command I was using:

Code:
grep -rH "mysql_connect" ./public_html/*
Any help is appreciated.

Thanks.
 
Old 06-05-2009, 10:09 AM   #2
jimbo1708
Member
 
Registered: Jan 2007
Location: Pennsylvania
Distribution: Ubuntu 8.10 Server/9.04 Desktop, openSUSE 11.1
Posts: 154

Rep: Reputation: 31
try this

Code:
grep -rH "mysql_connect" ./public_html/* >> output.dat
or if you have an email server set up on your machine

Code:
grep -rH "mysql_connect" ./public_html/* | sendmail joe.schmoe@domain.com
*****EDIT******
Corrected pipe as per druuna's recommendation. I guess I wasn't thinking

Last edited by jimbo1708; 06-05-2009 at 10:26 AM.
 
Old 06-05-2009, 10:19 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
@jimbo1708:
Quote:
grep -rH "mysql_connect" ./public_html/* || sendmail joe.schmoe@domain.com
That is not correct, hopefully a typo but there should be 1 pipe character not 2.

grep -rH "mysql_connect" ./public_html/* | sendmail joe.schmoe@domain.com

Depending on your setup (sendmail doesn't send mail from/to local lan on my boxes) you can also try mail or mailx (syntax is the same).
 
  


Reply



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
how does recursive grep work? serutan Linux - Newbie 5 07-11-2008 01:00 PM
recursive grep xpucto Solaris / OpenSolaris 2 05-29-2007 09:57 AM
postfix unable to send mail. log posted WOP1337 Linux - Server 1 03-15-2007 10:39 PM
Cannot send mail due to exim log file permission zahoo Linux - General 3 11-03-2005 11:42 AM
Recursive grep jimieee Linux - General 5 10-06-2003 10:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration