bkreynolds48
asked on
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
##########################
# 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
ASKER
the find by itself works fine
###########
find /home/userid/sql/awr -type f -name '*awr*.html*' -mtime -1 -print
/home/userid/sql/awr/awr_r pt-ORADEV. 06-16-15.h tml
###########
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
###########
find /home/userid/sql/awr -type f -name '*awr*.html*' -mtime -1 -print
/home/userid/sql/awr/awr_r
###########
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
"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.
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.
ASKER
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/oracl e
export ORACLE_ADMIN=/u01/app/orac le/admin
export ORACLE_HOME=/u01/app/oracl e/product/ 11.2.0/112 04
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_r pt-&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.a wr_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_rp t-ORADEV.0 6-16-15.ht ml
+ /usr/bin/mailx -s daily awr userid@mydomain.com
+ /usr/bin/uuencode -m /home/userid/sql/awr/awr_r pt-ORADEV. 06-16-15.h tml /home/userid/sql/awr/awr_r pt-ORADEV. 06-16-15.h tml
#############
email body text (partial)
#############
begin-base64 644 /home/userid/sql/awr/awr_r pt-ORADEV. 06-16-15.h tml
CjxodG1sIGxhbmc9ImVuIj48aG VhZD48dGl0 bGU+QVdSIF JlcG9ydCBm b3IgREI6IE FJSFJYUFJE
LCBJbnN0OiBhaWhyeHByZCwgU2 5hcHM6CiA1 NzcwMS01Nz cyMzwvdGl0 bGU+ICAgIC AgICAgICAg
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/oracl
export ORACLE_ADMIN=/u01/app/orac
export ORACLE_HOME=/u01/app/oracl
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_r
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.a
(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
/u01/app/oracle/product/11
+ cd /home/userid/sql/awr
+ + /usr/bin/find /home/userid/sql/awr -type f -name *awr*.html* -mtime -1 -print
filename=/home/userid/sql/
+ /usr/bin/mailx -s daily awr userid@mydomain.com
+ /usr/bin/uuencode -m /home/userid/sql/awr/awr_r
#############
email body text (partial)
#############
begin-base64 644 /home/userid/sql/awr/awr_r
CjxodG1sIGxhbmc9ImVuIj48aG
LCBJbnN0OiBhaWhyeHByZCwgU2
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.
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.
ASKER
OK
updated the PATH and took out the -m
- I get the email with no text in the body and no attachment
updated the PATH and took out the -m
- I get the email with no text in the body and no attachment
Did you see the filename in your trace as before, like
filename=/home/userid/sql/ awr/awr_rp t-ORADEV.0 6-16-15.ht ml ?
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?
filename=/home/userid/sql/
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?
ASKER
I see the filename and the path in the trac
that worked
I got the attachment
but the name is
homeuseridawrawr_rpt-ORADE V06-16-15. html
did I do something wrong?
that worked
I got the attachment
but the name is
homeuseridawrawr_rpt-ORADE
did I do something wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
ASKER
Excellent!
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"!