Hi All,
I have the below code(.sh) and need to send an email.
#!/bin/bash
cp /u02/xxc_incoming/TEST*.dat /u02/xxc_archive_incoming/AMER7764_ARPP_2/
cat /u02/xxc_incoming/TEST*.dat > /u02/xxc_incoming/XXC_TEST.dat
rm /u02/xxc_incoming/TEST*.dat
cd $XXC_TOP/bin
sqlldr userid=apps/<pwd> control=/u02/xxc/1.0/bin/XXC_INSERT.ctl rows=1
cat /u02/xxc_incoming/XXC_TEST.dat >> /u02/xxc_archive_incoming/AMER7764_ARPP_2/XXC_TEST.txt
Program log is showing below messages , if this one or some thing error occurs so then send an email.
cp: cannot stat �/u02/xxc_incoming/TEST*.dat': No such file or directory
cat: /u02/xxc_incoming/TEST*.dat: No such file or directory
rm: cannot remove �/u02/xxc_incoming/TEST*.dat': No such file or directory
could you please help me?
Thank you
log=$({
cp /u02/xxc_incoming/TEST*.dat /u02/xxc_archive_incoming/AMER7764_ARPP_2/
cat /u02/xxc_incoming/TEST*.dat > /u02/xxc_incoming/XXC_TEST.dat
rm /u02/xxc_incoming/TEST*.dat
} 2>&1) || echo "$log" | mutt -s "ERROR" Mist123@google.com
1 Like
Thank you so much
I have written like below(total code).
#!/bin/bash
log=$({
cp /u02/xxc_incoming/TEST*.dat /u02/xxc_archive_incoming/AMER7764_ARPP_2/
cat /u02/xxc_incoming/TEST*.dat > /u02/xxc_incoming/XXC_TEST.dat
rm /u02/xxc_incoming/TEST*.dat
} 2>&1) || echo "$log" | mutt -s "ERROR" Mist123@google.com
cd $XXC_TOP/bin
sqlldr userid=apps/<pwd> control=/u02/xxc/1.0/bin/XXC_INSERT.ctl rows=1
cat /u02/xxc_incoming/XXC_TEST.dat >> /u02/xxc_archive_incoming/AMER7764_ARPP_2/XXC_TEST.txt
sendmail: fatal: parameter inet_interfaces: no local interface found for ::1
Error sending message, child exited 75 (Deferred.).
Could not send the message.
SQLLoader-500: Unable to open file (/u02/xxc/1.0/bin/XXC_INSERT.ctl)
SQLLoader-553: file not found
SQL*Loader-509: System error: No such file or directory
Hi @Mist123,
Use the email client that you have configured, maybe "mail"?
Yes i used my company email in test instance.
Googling the sendmail error message, it looks like the latest "postfix" cannot start if IPv6 is not configured.
Can you please help me on this?
What is your SMTP mail service? (sendmail? postfix? exim? qmail?)
It is not running and/or not correctly configured.
The SMTP mail service must be started with root rights.
Some SMTP mailers (e.g. sendmail) can be configured to directly send mail without a running service.
It is not configured but i checked mutt is installed in our application server.
echo "$log" | mutt -s "ERROR" Mist123@google.com
how to change this to mailx?
echo "$log" | mailx -s "ERROR" user@domain
But the problem will remain: both mutt and mailx need a working SMTP mail service.
Thank you so much!
I am trying to add a message body how to add? with request-id.
requestid=`(echo $1 | cut -f2 -d' ' | cut -f2 -d= | tr -d '"' )`
echo "Request Id:" $requestid
Could you please help me?
Thank you
You can use another { } code bundle:
log=$(
{
cp /u02/xxc_incoming/TEST*.dat /u02/xxc_archive_incoming/AMER7764_ARPP_2/
cat /u02/xxc_incoming/TEST*.dat > /u02/xxc_incoming/XXC_TEST.dat
rm /u02/xxc_incoming/TEST*.dat
cd $XXC_TOP/bin
sqlldr userid=apps/<pwd> control=/u02/xxc/1.0/bin/XXC_INSERT.ctl rows=1
cat /u02/xxc_incoming/XXC_TEST.dat >> /u02/xxc_archive_incoming/AMER7764_ARPP_2/XXC_TEST.txt
} 2>&1
)
if [ -n "$log" ]
then
{
echo "Request Id: $requestid"
echo "$log"
} | mailx ...
fi
I used your code and it was sending an email even though if I have the file in /u02/xxc_incoming path.
Can you please suggest?