Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Background process and grep

Status
Not open for further replies.

ManagerJay

IS-IT--Management
Jul 24, 2000
302
US
I have started a process in the background and have been able to send its output to a file. Now, I am trying to only save lines that are output containing deliver.c:257.

I have tried the following without any luck.

/hdd2/jabber-1.4.2/jabberd/jabberd -D 2> grep deliver.c:257 > jabber.log &

/hdd2/jabber-1.4.2/jabberd/jabberd -D | grep deliver.c:257 >/hdd2/jabber.log &

And, other variations of the same line. I am either getting all of the output or none of the output.

Any suggestions would be greatly appreciated. Thanks in advance for your assistance.



Jay Hall
 
Try using quotation marks....

/hdd2/jabber-1.4.2/jabberd/jabberd -D | grep "deliver.c:257" > /hdd2/jabber.log &

or

/hdd2/jabber-1.4.2/jabberd/jabberd -D | grep 'deliver.c:257' > /hdd2/jabber.log &

What is jabberd -D and what does it do? Does it continually send output to the screen or does it send it all at once?


ChrisP ---------------------------------------
If someone's post was helpful to you, please click the box "Click here to mark this post as a helpful or expert post".
 
Jabber is an instant messaging server the organization I work for has setup (
In order to protect ourselves, we want to save a log of any conversations on the server.

The -D option basically puts the daemon into debug mode so everything the daemon does is output. The deliver.c:257 is output whenever a message is sent to a user and since it contains to and from information, as well as times, it should provide the information needed. From start to finish I would say it took less than three hours to set everything up and that includes interruptions.

Thanks for your help.



Jay
 
Did it work with the quotation marks?

ChrisP ---------------------------------------
If someone's post was helpful to you, please click the box "Click here to mark this post as a helpful or expert post".
 
To be anal with the grep reg expression, try...

/hdd2/jabber-1.4.2/jabberd/jabberd -D | grep 'deliver\.c:257' > /hdd2/jabber.log &

In a grep regular expression, a period will be expanded to represent "one of any character".
I've added a backslash before the period which tells grep that the period is a literal and not some character.

thanks for allowing me to be anal. :)

 
No, it did not work so I decided to try something to ensure I knew what I was doing with grep, etc., but I think I have a mistake somewhere else.

ping 10.129.10.40 | grep "ttl" > /hdd2/test.log

This just gives me an empty file. However, if I run it without > everything displays to the screen just fine.

Any suggestions would be greatly appreciated.


Thanks,



Jay
 
Try your ping example but let it ping a set number of times.

ping -c8 10.129.10.40 | grep "ttl" > /hdd2/test.log

This worked for me. Perhaps it's not working correctly because you kill the process. Maybe a buffering issue? How are you terminating the 'jabber' example given above?

jaa
 
Using -c8 worked just like it should have. I have been killing the jabber process using the kill command. Is there a better way to do this?

Thanks for your help.



Jay
 
linmatty - won't the quotation marks cancel out the special meaning of the backslash along with the period too?

---------------------------------------
If someone's post was helpful to you, please click the box "Click here to mark this post as a helpful or expert post".
 
Will Ctrl+C or Ctrl+D stop the process?

If you ran the process without grep like this below, does it send all of the output to the text file?

/hdd2/jabber-1.4.2/jabberd/jabberd -D > /hdd2/jabber2.log &

If it does, this isn't as convenient, but you can create a simple script that will grep the text file afterwards and remove the temp file...

grep "deliver.c:257" jabber2.log > jabber.log
rm -f jabber2.log


ChrisP ---------------------------------------
If someone's post was helpful to you, please click the box "Click here to mark this post as a helpful or expert post".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top