production of and scheduling sun unix - solaris - job to move a csv file to a user via email

at the moment cron runs a weekly job which interrogates a db and produces a set of csv files which reside in a folder on the same sun server.

I need to work out the easiest way to set up a job which will transfer these files to an email address preferably.
pauldvincentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omarfaridCommented:
You may send them to an email by running a crontab job at required time which will send them one by one.

#!/usr/bin/ksh
cd /to/my/dir
for file in *.csv
do
    /usr/bin/cat $file | /usr/bin/mailx -s "text subject" user@domain.com >> /to/my/log/script.log 2>>&1
done
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
casemanagerCommented:
Greetings,

If I understand correctly you wish to convert the cron results into an email and which is then sent to the user.

By default cron jobs sends a email to the user account executing the cronjob. If this is not working you can place the following command at the top of the crontab file,

MAILTO=emaiid@domain.com

try it and let me know if it works for you.

Regards,
Casemanager
0
omarfaridCommented:
Hi casemanager,

Sun Solaris crontab does not support MAILTO env. variable.

0
bummerlordCommented:
Do you need to preserve the files as attachments or is it sufficient to have the file content in the email message body, one message per csv file?
if yes, comment #1 would be your accepted answer.
0
pauldvincentAuthor Commented:
apologies for not getting back sooner - I am on dialysis and am not always up to working. omarfarid's solution works just as I want it to. Thanks casemanager for looking as well, and bummerlord for reinforcing the solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.