unix mailx .html file

trying to mailx my .html file - get the following errors

###############################
# end of the report file
#
exit
EOF
#
filename=`find /home/userid/sql/awr -type f -name '*awr*.html*' -mtime -1 -print`
/usr/bin/uuencode  $filename |mailx -s  "daily awr"  userid@mymail.com

############
#output from report file
#
End of Report
</body></html>
+ + find /home/bkbelk/sql/awr -type f -name *awr*.html* -mtime -1 -print
./awr_rpt.ksh[44]: find:  not found.
filename=
+ mailx -s daily awr  userid@mymail.com
+ /usr/bin/uuencode
./awr_rpt.ksh[45]: mailx:  not found.
Usage:  uuencode [-m] [infile] remotefile

##################################

adding the "-m"
############
# end of the report file
#
exit
EOF
#

filename=`find /home/userid/sql/awr -type f -name '*awr*.html*' -mtime -1 -print`
/usr/bin/uuencode -m  $filename |/usr/bin/mailx -s  "daily awr"    userid@mymail.com

############
#output from report file
#
./awr_rpt.ksh[44]: find:  not found.
filename=
+ mailx -s daily awr  userid@mymail.com
+ /usr/bin/uuencode -m
./awr_rpt.ksh[45]: mailx:  not found.
Usage:  uuencode [-m] [infile] remotefile
Null message body; hope that's ok

###########
I get an email but no attachment
LVL 1
bkreynolds48Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

woolmilkporcCommented:
uuencode needs two parameters:

1) the name of the input file
2) the name to be given this file on the remote side by "uudecode" and quasi "name of attachment" .

The first name can be omitted if and only if there is input from stdin.

The optional "-m" means "MIME compatible encoding format".
Note: Not all recipients understand the MIME encoding.

The simplest form is this:

/usr/bin/uuencode  $filename $filename |/usr/bin/mailx -s  "daily awr"  userid@mymail.com

Moreover, there seems to be an issue with your PATH setting, because the "find" utility cannot be located by the shell. What is the PATH setting, and where does your "find" reside? Do you run the script via crontab?
Try "/usr/bin/find" instead of just "find"!
bkreynolds48Author Commented:
the find by itself works fine
###########
find /home/userid/sql/awr -type f -name '*awr*.html*' -mtime -1 -print
/home/userid/sql/awr/awr_rpt-ORADEV.06-16-15.html
###########

could the problem be the name of the file?

###########

+ + find /home/userid/sql/awr -type f -name *awr*.html* -mtime -1 -print
./awr_rpt.ksh[44]: find:  not found.
filename=
+ /usr/bin/mailx -s daily awr bkbelk@magellanhealth.com
+ /usr/bin/uuencode -m
Usage:  uuencode [-m] [infile] remotefile
Null message body; hope that's ok
woolmilkporcCommented:
"find" from command line works, that's right.

But it doesn't work from inside the script.

The filename to be searched (-name) must of course be enclosed in quotes if it contains globbing characters,
but that's what you did.
The name of the matching file doesn't matter, as long as it doesn't contain spaces or other stuff which might confuse the shell in the later processing, but that's not the case here.

Did you try "/usr/bin/find"?
Which is your OS?
Do you run the script from crontab?

It would be nice if you could post the whole script!
Or add "echo $PATH" on a line of its own just above "find .. ..." and post the result.
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

bkreynolds48Author Commented:
HERE is the script and the output with the echo
I see the path is wrong for the find so I tried putting a
cd /home/userid/sql/awr
so the path is correct now and the find works but
the email is not an attachment it is some kind of
garbage in the body of the email
######################################

########
#!/usr/bin/ksh
set -x
########
#
export ORACLE_BASE=/u01/app/oracle
export ORACLE_ADMIN=/u01/app/oracle/admin
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/11204
export PATH=$ORACLE_HOME/bin
#
export ORACLE_SID=$1
#
sqlplus -s '/as sysdba' << EOF
set echo off
set head off
set feed off

column name noprint new_value dbname;
select name from v\$database;
col today noprint new_value xdate
select to_char( sysdate, 'MM-DD-YY') today from dual;

spool /home/userid/sql/awr/awr_rpt-&dbname..&xdate..html

SELECT output
   FROM (SELECT MIN(snap_id) minid, MAX(snap_id) maxid
           FROM dba_hist_snapshot
          WHERE begin_interval_time >= TRUNC(SYSDATE) - 1 AND end_interval_time < TRUNC(SYSDATE)),
        TABLE(
            DBMS_WORKLOAD_REPOSITORY.awr_report_html(
                (SELECT dbid
                   FROM v\$database),
                (SELECT instance_number
                   FROM v\$instance),
                minid,
                maxid
            )
        )
/
spool off
exit
EOF
#
cd /home/userid/sql/awr
echo $PATH
filename=`/usr/bin/find /home/userid/sql/awr -type f -name '*awr*.html*' -mtime -1 -print`
/usr/bin/uuencode  -m  $filename $filename |/usr/bin/mailx -s  "daily awr"   userid@mydomain.com
#####################

output from the above
#####################

+ echo /u01/app/oracle/product/11.2.0/11204/bin
/u01/app/oracle/product/11.2.0/11204/bin
+ cd /home/userid/sql/awr
+ + /usr/bin/find /home/userid/sql/awr -type f -name *awr*.html* -mtime -1 -print
filename=/home/userid/sql/awr/awr_rpt-ORADEV.06-16-15.html
+ /usr/bin/mailx -s daily awr userid@mydomain.com
+ /usr/bin/uuencode -m /home/userid/sql/awr/awr_rpt-ORADEV.06-16-15.html /home/userid/sql/awr/awr_rpt-ORADEV.06-16-15.html

#############
email body text (partial)
#############

begin-base64 644 /home/userid/sql/awr/awr_rpt-ORADEV.06-16-15.html
CjxodG1sIGxhbmc9ImVuIj48aGVhZD48dGl0bGU+QVdSIFJlcG9ydCBmb3IgREI6IEFJSFJYUFJE
LCBJbnN0OiBhaWhyeHByZCwgU25hcHM6CiA1NzcwMS01NzcyMzwvdGl0bGU+ICAgICAgICAgICAg
woolmilkporcCommented:
OK.

The PATH statement near the top of your script is incomplete:

export PATH=$ORACLE_HOME/bin

should rather read:

export PATH=$ORACLE_HOME/bin:$PATH

What you see in the email body is not really "garbage". It's the base64 (MIME) encoded HTML file.

It seems that the email client at the receiving side does not know how to decode base64.
Please try "uuencode" without the "-m" flag, so the standard UU encoding format wil be used.

Let's see.
bkreynolds48Author Commented:
OK
updated the PATH and took out the -m

 - I get the email with no text in the body and no attachment
woolmilkporcCommented:
Did you see the filename in your trace as before, like
filename=/home/userid/sql/awr/awr_rpt-ORADEV.06-16-15.html ?

Did you see any error messages from find/uuencode/mailx ?

Please repeat the whole run, keeping the updated PATH but re-adding -m. Do you see the garbage?
bkreynolds48Author Commented:
I see the filename and the path in the trac
that worked
I got the attachment
but the name is

homeuseridawrawr_rpt-ORADEV06-16-15.html

did I do something wrong?
woolmilkporcCommented:
>> I got the attachment <<

With or without "-m"?

Was the attachment readable, despite of its ugly name?

It seems that for some reason the receiving client doesn't see (or like) the slashes.

Please try this:

/usr/bin/uuencode  $filename $(basename $filename) | /usr/bin/mailx -s  "daily awr"   userid@mydomain.com

This will strip the whole path component, sending just awr_rpt-ORADEV.06-16-15.html   as the attachment name to the recipient.

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
bkreynolds48Author Commented:
without the "-m"

this worked
/usr/bin/uuencode  $filename $(basename $filename) | /usr/bin/mailx -s  "daily awr"   userid@mydomain.com


the attachment comes as an html file and is very readable
thanks so much for your help
bkreynolds48Author Commented:
Excellent!
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.