Bumped by Community user
    Bumped by Community user
3 edited tags
| link
2 code is not formated as it should be
source | link

!/usr/bin/sh

SHDIR=/oracle/CMC/scripts/utils/SCTempConst

export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP

cd $SHDIR

TO= BCC=

if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ] then SUBJECT="Subject ...."

ATTCH=SCTempConst.xlsx

export TO BCC SUBJECT ATTCH SHDIR ./BNSendMail.sh

fi

#!/usr/bin/sh

SHDIR=/oracle/CMC/scripts/utils/SCTempConst

export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP

cd $SHDIR

TO=<actual email address>
BCC=<actual email address>

if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ]
then
SUBJECT="Subject ...."

ATTCH=SCTempConst.xlsx

export TO BCC SUBJECT ATTCH SHDIR
./BNSendMail.sh

fi

the BNSendmail is as follows:

!/bin/bash

cd ${SHDIR} FROM=""

boundary="ZZ_/afg6432dfgkl.94531q" body=cat msg.txt

Build headers

{

printf '%s\n' "From: $FROM To: $TO Cc: $CC Bcc: $BCC Subject: $SUBJECT Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=\"$boundary\"

--${boundary} Content-Type: text/plain; charset=\"US-ASCII\" Content-Transfer-Encoding: 7bit Content-Disposition: inline

$body "

mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

printf '%s\n' "--${boundary} Content-Type: $mimetype1 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"${ATTCH}\" "

base64 "${SHDIR}/${ATTCH}" echo

print last boundary with closing --

printf '%s\n' "--${boundary}--"

} | sendmail -t -oi

#!/bin/bash

cd ${SHDIR}
FROM="<from email id>"

boundary="ZZ_/afg6432dfgkl.94531q"
body=`cat msg.txt`

# Build headers
{

printf '%s\n' "From: $FROM
To: $TO
Cc: $CC
Bcc: $BCC
Subject: $SUBJECT
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=\"$boundary\"

--${boundary}
Content-Type: text/plain; charset=\"US-ASCII\"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

$body
"

mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

printf '%s\n' "--${boundary}
Content-Type: $mimetype1
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"${ATTCH}\"
"

base64 "${SHDIR}/${ATTCH}"
echo

# print last boundary with closing --
printf '%s\n' "--${boundary}--"

} | sendmail -t -oi 

!/usr/bin/sh

SHDIR=/oracle/CMC/scripts/utils/SCTempConst

export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP

cd $SHDIR

TO= BCC=

if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ] then SUBJECT="Subject ...."

ATTCH=SCTempConst.xlsx

export TO BCC SUBJECT ATTCH SHDIR ./BNSendMail.sh

fi

the BNSendmail is as follows:

!/bin/bash

cd ${SHDIR} FROM=""

boundary="ZZ_/afg6432dfgkl.94531q" body=cat msg.txt

Build headers

{

printf '%s\n' "From: $FROM To: $TO Cc: $CC Bcc: $BCC Subject: $SUBJECT Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=\"$boundary\"

--${boundary} Content-Type: text/plain; charset=\"US-ASCII\" Content-Transfer-Encoding: 7bit Content-Disposition: inline

$body "

mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

printf '%s\n' "--${boundary} Content-Type: $mimetype1 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"${ATTCH}\" "

base64 "${SHDIR}/${ATTCH}" echo

print last boundary with closing --

printf '%s\n' "--${boundary}--"

} | sendmail -t -oi

#!/usr/bin/sh

SHDIR=/oracle/CMC/scripts/utils/SCTempConst

export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP

cd $SHDIR

TO=<actual email address>
BCC=<actual email address>

if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ]
then
SUBJECT="Subject ...."

ATTCH=SCTempConst.xlsx

export TO BCC SUBJECT ATTCH SHDIR
./BNSendMail.sh

fi

the BNSendmail is as follows:

#!/bin/bash

cd ${SHDIR}
FROM="<from email id>"

boundary="ZZ_/afg6432dfgkl.94531q"
body=`cat msg.txt`

# Build headers
{

printf '%s\n' "From: $FROM
To: $TO
Cc: $CC
Bcc: $BCC
Subject: $SUBJECT
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=\"$boundary\"

--${boundary}
Content-Type: text/plain; charset=\"US-ASCII\"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

$body
"

mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

printf '%s\n' "--${boundary}
Content-Type: $mimetype1
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"${ATTCH}\"
"

base64 "${SHDIR}/${ATTCH}"
echo

# print last boundary with closing --
printf '%s\n' "--${boundary}--"

} | sendmail -t -oi 
1
source | link

cronjob bash script called within another shell script not working

I have a shell script which calls a bash script within it. when I run this shell script manually it works fine however when I schedule this thru cronjob, the bash script is not doing the intended job.

shell script is as follows:

!/usr/bin/sh

SHDIR=/oracle/CMC/scripts/utils/SCTempConst

export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP

cd $SHDIR

TO= BCC=

if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ] then SUBJECT="Subject ...."

ATTCH=SCTempConst.xlsx

export TO BCC SUBJECT ATTCH SHDIR ./BNSendMail.sh

fi

the BNSendmail is as follows:

!/bin/bash

cd ${SHDIR} FROM=""

boundary="ZZ_/afg6432dfgkl.94531q" body=cat msg.txt

Build headers

{

printf '%s\n' "From: $FROM To: $TO Cc: $CC Bcc: $BCC Subject: $SUBJECT Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=\"$boundary\"

--${boundary} Content-Type: text/plain; charset=\"US-ASCII\" Content-Transfer-Encoding: 7bit Content-Disposition: inline

$body "

mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

printf '%s\n' "--${boundary} Content-Type: $mimetype1 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"${ATTCH}\" "

base64 "${SHDIR}/${ATTCH}" echo

print last boundary with closing --

printf '%s\n' "--${boundary}--"

} | sendmail -t -oi

As I said this is working perfectly fine when execute manually. only when I set this as a cronjob, its not emailing.

any help is appreciated.

Thanks and regards, basu