LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Automatic email-with Subject line containing the previous date (https://www.linuxquestions.org/questions/linux-newbie-8/automatic-email-with-subject-line-containing-the-previous-date-938407/)

pnandak 04-05-2012 11:51 PM

Automatic email-with Subject line containing the previous date
 
Hi,
Below is the Query i use to get Automatic mail from unix

nohup bteq <pn_store_info_2011.bteq> store_transaction.out 2>&1 &
wait

/opt/sas/SAS_9.1/sasexe/sas store_transaction.sas
wait

/*zip SAC_Tire SAC_Tire.xls*/
(cat store-message.txt; uuencode Store_Level_Trans.xls Store_Level_Tran.xls) | mailx -s "Store Level Transaction Report" -r "Automotive " `cat mailpcp_Store.dat`

my query is - the subject line should be like "Store Level Transaction Report-April 04/2012" that is i will be running the code daily and my subjcet should contain yesterday date.

2. also my attachment also should have the yesterday date.
i Tried few option but not working.
Any help would be Great.pls..
pls. help

catkin 04-06-2012 12:01 AM

date -d yesterday gives yesterday's date. It can be formatted as required using the +FORMAT argument.

pnandak 04-06-2012 12:07 AM

(cat store-message.txt; uuencode Store_Level_Trans.xls Store_Level_Tran.xls) | mailx -s "Store Level Transaction Report"date -d yesterday -r "Automotive " `cat mailpcp_Store.dat`

I tried the above one- but i didnt recieve the mail.also my Attachment Store_Level_Trans.xls should be Store_Level_Trans_Yesterday.xls ..

New to coding- so pls. help

pnandak 04-09-2012 12:10 AM

Any help on the above said issue..

pnandak 04-10-2012 01:51 AM

got what i needed-
-----------------
yest=$(TZ=EST24EDT date '+%x')
yest1=$(TZ=EST24EDT date '+%Y%m%d')
mv Store_Level_Trans.xls Store_Level_Trans_$yest1.xls

(cat store-message.txt; uuencode Store_Level_Trans_$yest1.xls Store_Level_Trans_$yest1.xls && uuencode Query_Used.txt Query_Used.txt) | mailx -s "Store Level Transaction Report on $yest " -r "Automotive " `cat mailpcp_Store.dat`
-----------------------------
Worked !!


All times are GMT -5. The time now is 03:22 AM.