Re: help!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Kwan wrote:
> On Wed, Mar 24, 2010 at 4:48 AM, Roland RoLaNd <r_o_l_a_n_d@xxxxxxxxxxx>
> wrote:
>>
>> i've just wrote the following :
             ^^^^^ written
>>
>> more ./*.csv | grep -i XXX | echo "Dear XXX, This email is for
>> informative purposes. Your total number of hours for the week of `date`
>> is: `cut  -d, -f2` hours  Kindly note that the average weekly working
>> hours is : 40." | /usr/sbin/sendEmail -t mail@xxxxxxxxxx -u Test email-
>> disregard it  -f othermail@xxxxxxxxxxxxx -s smtp.domain.com:25
<snip>
>> 1. i have to fill the name for each person in place of XXX as well as
>> their MAIL@xxxxxxxxxx
>> 2. the date command gives the hour as well which is a bit annoying
>>
>> can anyone guide me on how to proceed?
<snip>
> :D  I had a similar assignment once..  The cleanest approach is to use
> awk instead of grep and cut.  With awk you can specify fields in the
> input as $2, $3, etc..

Yep. awk's the tool you want (I can hear the perl Is The Answer believers
yelling <g>).
awk -v DATE=`date` -f yourscript.awk
would pass the system date in.
Beyond that, the script's incredibly simple, if all your data is in the
.csv, and all on one line. The final email could be sent either by doing
cmd = "echo " awkvariable " | email -s woohoo " $<whatver field number the
username is>";
system cmd;
or you can have awk print it out, and pipe the output of awk through mail.
I think the former's cleaner.

          mark

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux