|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 &
|
|
#2
|
||||
|
||||
|
/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 & |
|
#3
|
||||
|
||||
|
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? |
|
#4
|
||||
|
||||
|
/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. |
|
#5
|
||||
|
||||
|
Thanks for the help.... appreciated......
![]() |
|
#6
|
||||
|
||||
|
Not a problem.
Test it out make sure it works -- I didn't, and I could certainly have made a typo somewhere. |
|
#7
|
||||
|
||||
|
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? |
|
#8
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > BSD Help > Shell Script advise required - Writing contents to a file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|