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:
  #1  
Old April 15th, 2003, 07:10 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
Shell Script advise required - Writing contents to a file

Basically we have a shell script that we use to run and configure the UDM search indexer on the server.

The script compiles the logs of the search results of the indexing process and emails them to an admin user. However the emails are getting rather large.

What I would like to know is what do I need to do to change the lines below to actually write the log to a log file on the server, and then just email the user saying it was completed, with a link to the log filename??

The script is a shell script running on Free BSD.

Code:
/bin/sh -c "( echo -e 'Started at-:'; /bin/date ; echo '';
(${UDM_INDEXER} 2>&1);echo -e -n '\nEnded at-:'; /bin/date;  ) 
| mail -s 'PIRSA UDM Indexer finshed'
 ${EMAIL_USER}; " > /dev/null &

Reply With Quote
  #2  
Old April 22nd, 2003, 10:36 PM
rfc791's Avatar
rfc791 rfc791 is offline
unix hermit
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: http://www.rfc791.org
Posts: 18 rfc791 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0

/bin/sh -c "( echo -e 'Started at-:'; /bin/date ; echo '';
(${UDM_INDEXER} 2>&1);echo -e -n '\nEnded at-:'; /bin/date; )
>/tmp/udmout && echo 'udm index complete at /tmp/udmout' |
mail -s 'PIRSA UDM Indexer finshed'
${EMAIL_USER}; " > /dev/null &


or email and file


/bin/sh -c "( echo -e 'Started at-:'; /bin/date ; echo '';
(${UDM_INDEXER} 2>&1);echo -e -n '\nEnded at-:'; /bin/date; )
| tee /tmp/udmout | mail -s 'PIRSA UDM Indexer finshed'
${EMAIL_USER}; " > /dev/null &

Reply With Quote
  #3  
Old April 23rd, 2003, 07:07 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
So using:-

/bin/sh -c "( echo -e 'Started at-:'; /bin/date ; echo '';
(${UDM_INDEXER} 2>&1);echo -e -n '\nEnded at-:'; /bin/date; )
>/tmp/udmout && echo 'udm index complete at /tmp/udmout' |
mail -s 'PIRSA UDM Indexer finshed'
${EMAIL_USER}; " > /dev/null &

That will write the contents to a file and still send the email just advising the task is completed??

how would I have the filename include the date it was run, and also include the filename in the body of the email?

Reply With Quote
  #4  
Old April 24th, 2003, 12:41 AM
rfc791's Avatar
rfc791 rfc791 is offline
unix hermit
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: http://www.rfc791.org
Posts: 18 rfc791 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0


/bin/sh -c "( echo -e 'Started at-:'; /bin/date ; echo '';
(${UDM_INDEXER} 2>&1);echo -e -n '\nEnded at-:'; /bin/date; )
>/tmp/udmout`date +%Y.%m.%d` &&
echo "udm index complete at /tmp/udmout`date +%Y.%m.%d`" |
mail -s 'PIRSA UDM Indexer finshed'
${EMAIL_USER}; " > /dev/null &



That'll be $65, please

Last edited by rfc791 : April 24th, 2003 at 12:43 AM.

Reply With Quote
  #5  
Old April 24th, 2003, 12:47 AM
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
Thanks for the help.... appreciated......


Reply With Quote
  #6  
Old April 24th, 2003, 12:57 AM
rfc791's Avatar
rfc791 rfc791 is offline
unix hermit
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: http://www.rfc791.org
Posts: 18 rfc791 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Not a problem.

Test it out make sure it works -- I didn't, and I could certainly have made a typo somewhere.

Reply With Quote
  #7  
Old April 28th, 2003, 01:30 AM
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 using:-

/bin/sh -c "( echo -e 'Started at-:'; /bin/date ; echo ''; (${UDM_INDEXER} 2>&1);echo -e -n '\nEnded at-:'; /bin/date; ) >/web/udmlogs/sus_res_`date +%Y.%m.%d` && echo "udm index complete at /web/udmlogs/sus_res_`date +%Y.%m.%d`" | mail -s 'Sustainable UDM Indexer finshed' ${EMAIL_USER}; " > /dev/null &

it creates the file correctly not a problem, however there is no notification email sent to the user after completion...

any suggestions?

Reply With Quote
  #8  
Old April 28th, 2003, 10:38 PM
rfc791's Avatar
rfc791 rfc791 is offline
unix hermit
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: http://www.rfc791.org
Posts: 18 rfc791 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hmm ... something must be giving you a nonzero exit value for some reason. Try this:



/bin/sh -c "( echo -e 'Started at-:'; /bin/date ; echo ''; (${UDM_INDEXER} 2>&1);echo -e -n '\nEnded at-:'; /bin/date; ) >/web/udmlogs/sus_res_`date +%Y.%m.%d` ; echo "udm index complete at /web/udmlogs/sus_res_`date +%Y.%m.%d`" | mail -s 'Sustainable UDM Indexer finshed' ${EMAIL_USER}; " > /dev/null &


Actually, looking back at your original script, I notice an unneeded semicolon and quote at the end of it that may be confusing the shell, try this:


/bin/sh -c "( echo -e 'Started at-:'; /bin/date ; echo ''; (${UDM_INDEXER} 2>&1);echo -e -n '\nEnded at-:'; /bin/date; ) >/web/udmlogs/sus_res_`date +%Y.%m.%d` && echo "udm index complete at /web/udmlogs/sus_res_`date +%Y.%m.%d`" | mail -s 'Sustainable UDM Indexer finshed' ${EMAIL_USER}> /dev/null &

Last edited by rfc791 : April 28th, 2003 at 10:44 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsBSD Help > Shell Script advise required - Writing contents to a file


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 6 hosted by Hostway