|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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. |
|
#2
|
|||
|
|||
|
Add | /usr/bin/tee -a /path/to/log_file before doing stdout to /usr/bin/mail. Man tee(1) for more details.
|
|
#3
|
||||
|
||||
|
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..... |
|
#4
|
|||
|
|||
|
>> 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. |
|
#5
|
||||
|
||||
|
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. |
|
#6
|
|||
|
|||
|
>> 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, 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. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > BSD Help > Question regarding output redirection |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|