BSD Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsBSD Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 14th, 2002, 08:47 PM
mystik_web's Avatar
mystik_web mystik_web is offline
No one Important
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Australia
Posts: 524 mystik_web User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 38 m 24 sec
Reputation Power: 8
Send a message via ICQ to mystik_web
Question regarding output redirection

Hi there, I am still learning all this unix stuff, and would appreciate alittle help is possible.

We have the UDM indexer installed ont he machine that indexes the websites.

We currently have a shell script that runs the indexer over the website, and outputs the log of the index to an email by doing:-
Code:
/bin/sh -c "( echo 'Subject: Indexer finshed\n\n' ; echo -n 'Started at-:'; /sbin/date ; echo '';(${UDM_INDEXER} 2>&1);echo -n '\nEnded at-:'; /sbin/date; /sbin/rm -f .indexer.lock ) | mail ${EMAIL_USER}; " > /dev/null &


My question is what do I need to do to this string to split it into two parts...
1st part is to loop through and write the report to a log file, with the name of the website it was for and the date the files was run.

2nd part is to email the notification email advising that the indexer has completed its run and can be viewed at the following location.

If anyone could help me that would be great.

Reply With Quote
  #2  
Old August 14th, 2002, 09:44 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Add | /usr/bin/tee -a /path/to/log_file before doing stdout to /usr/bin/mail. Man tee(1) for more details.

Reply With Quote
  #3  
Old August 14th, 2002, 10:21 PM
mystik_web's Avatar
mystik_web mystik_web is offline
No one Important
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Australia
Posts: 524 mystik_web User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 38 m 24 sec
Reputation Power: 8
Send a message via ICQ to mystik_web
sorry for being a pain, so in the context of above, how would the final string appear?

I do not want to log details $[UDM_INDEXER] being sent to mail, i want this part sent to the file. and a simple mail sent informing it has been run.....

Reply With Quote
  #4  
Old August 15th, 2002, 10:50 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> I do not want to log details $[UDM_INDEXER] being sent to mail

Then don't 2>&1 it.

>> and a simple mail sent informing it has been run

Then 2>&1 when tee finishes its job.

You also need not to send your Subject that way. Just use -s flag for mail(1). If you run FreeBSD you even can use -E flag to skip empty body.

Reply With Quote
  #5  
Old August 15th, 2002, 08:35 PM
mystik_web's Avatar
mystik_web mystik_web is offline
No one Important
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Australia
Posts: 524 mystik_web User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 38 m 24 sec
Reputation Power: 8
Send a message via ICQ to mystik_web
Hey there thanks for the help, but I still think I am confused with the layout of the string. Looking at it, should it be like:-

/bin/sh -c "(echo 'Started at-:'; /sbin/date ; echo '';(${UDM_INDEXER} | /usr/bin/tee -a /path/to/log_file./sbin/date; 2>&1 );echo -n '\nEnded at-:'; /sbin/date; /sbin/rm -f .indexer.lock )| mail ${EMAIL_USER} -s "Search Indexer has Finished" -e; " > /dev/null &

I want the filnemae to include the date it was run so we can have incremental logs.

Reply With Quote
  #6  
Old August 17th, 2002, 10:15 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> I still think I am confused with the layout of the string

That's why you are not supposed to use one-liner if you can't write such a script. Further, the path to date and rm are incorrect. You also can't append the date as the extension to the log file. You need to select a date format (default doesn't work), say month in numerical format:
Code:
tee -a /path/to/log_file.`date +%H`
Anyway, getting the mail is a piece of cake, whether you get what you want in your log file is another story, as it depends on how your UDM_INDEXER works. If it puts itself into the background then it won't work as it sends nothing to stdout.
Anyway, I'm going to end here because this topic was off-topic right from the beginning. UNIX forum is a better forum for such topic because there isn't a Shell Script forum.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsBSD Help > Question regarding output redirection


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway