unable to do mailx from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unable to do mailx from shell script
# 1  
Old 12-20-2002
unable to do mailx from shell script

Hi

From within a shell script my mailx doesnt seem to work...can somebody tell me what is wrong...

#!/bin/ksh
#Script to verify wheather all databases listed are up and running
#Script works with Oracle8 and above databases
#Script has to be run by ./scriptname
DBA=xiamin@unix.com
echo $DBA
PLATFORM=`uname`
if [ ${PLATFORM} != "SunOS" ]; then
ORATAB="/etc/oratab" #Digital Unix
else
ORATAB="/var/opt/oracle/oratab" #SunOS
fi
ALL_DATABASES=`cat $ORATAB|grep -v "^#"|grep -v "N$"|cut -f1 -d: -s`
for DB in $ALL_DATABASES
do
unset TWO_TASK
export ORACLE_SID=$DB
echo $ORACLE_SID
export ORACLE_HOME=`grep "^${DB}:" $ORATAB|cut -d: -f2 -s`
echo $ORACLE_HOME
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib;
echo "---> Database $ORACLE_SID, using home $ORACLE_HOME"
STATUS=`sqlplus -s system/manager <<EOF
set pagesize 0 feedback off verify off heading off echo off
select status from v\\$instance;
exit;
EOF`
if [[ $STATUS = "OPEN" ]]; then
echo "Dude Database $ORACLE_SID on `uname -n` is Down check it " \
>>/tmp/db_status.log
fi
done
echo $PATH
if [[ -s $db_status.log ]]; then
mailx -s "Database status from `uname -n`" $DBA <db_status.log
fi

it does not mail me the file db_status.log at all..whereas from the command prompt using mailx i can send mails to myslef..

regards
xiamin
# 2  
Old 12-20-2002
Hi,

If mailx is working from the command prompt, one other reason can be that the file db_status.log may not be available.

If the input file db_status.log is not available , mailx does nothing.

Regards,
raju
# 3  
Old 12-20-2002
Hi,

You are generating the file in /tmp directory.So, are you running the script the the same directory because you are checking the file's existence in current directory and also for mailing.

One more thing is that you have used $db_status.log while checking if the file exists but while mailing you are using just db_status.log

May be you need to remove $ while checking for the existence of the file.

Regards,
raju
# 4  
Old 12-24-2002
Hi

Raju thank you for your help..i debugged the problem by littering my code with a lot of debug statements somethin like this..

func1 ()
echo "i ma enetering func1"
lottas of cpde
...........


func2()
echo "i am enetering func2"
loattas of code
......

The problem was with the following line..
if [[ -s $db_status.log ]];

my code never reached the line below it ..i cahnged it to..

if [[ -s db_status.log ]];

now every thing works..fine...

regards
xiamin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

2. Shell Programming and Scripting

[Solved] Unable to mailx new $pid for a script restart

Ill try to make this brief: I am trying to get the script below to run another script defined as BATNAM. The script runs fine, does what i designed it to do, however... I would like it to mailx the NEW $pid that was restarted. This script is supposed to go in crontab as root, and run by... (8 Replies)
Discussion started by: olyanderson
8 Replies

3. Solaris

Unable to send mail through mailx

Hi, I am using solaris 5.9 OS and I am facing an issues with mailx. My SMTP port is configured to listen 6190 and not the default one which is 25. I can send mail to my inbox when i do it manually through the following steps root@<dbname> # telnet 15.12.88.10 6190 Trying 15.12.88.10...... (0 Replies)
Discussion started by: Srinathkiru
0 Replies

4. UNIX for Dummies Questions & Answers

Mailx command in unix shell script, its throwing below error

How to use Mailx command in unix shell script, its throwing below error #!/bin/ksh let x=3 If ; then mailx -s “ $x is greater than 2” example@gmail.com << EOF This is the message body EOF fi its throwing error as syntax error at EOF... (10 Replies)
Discussion started by: only4satish
10 Replies

5. Linux

mailx: Unable to send Japanese

Hi All, I am facing problem in sending Japanese characters using mailx command in GNU linux machine. The mail is going with junk characters like "ใƒกใƒผใƒซใฎไธ-็•Œใธใ‚ˆใ†ใ“ใ". I tried changing the LANG value to japan locale off UTF-8. But it doesn't worked. I have to send the data as body not as an... (0 Replies)
Discussion started by: Karteek
0 Replies

6. Shell Programming and Scripting

unable to put cc list in mailx

Hi, I am using mailx command to send mail. But unable to use -c option to send mails by cc list. eg. ..mailx -s "subject" -c "CCLIST" "TOLIST" Its showing " illegal option -- c" I am using HP UX. Can anybody help me out. Thanks in advance..! (3 Replies)
Discussion started by: Kattoor
3 Replies

7. Shell Programming and Scripting

Unable to attache file in mailx

I have script to send report to the recipent along with a short decription of a message. But unfortunatly it fails to deliver the report as attachment nothing apart from the message come, please find the part where I am getting stuck and confused ... please check out if you have any better... (1 Reply)
Discussion started by: nicknihal
1 Replies

8. Shell Programming and Scripting

How to read email using mailx in shell script or perl

Hello, I am new to mailx and perl and I need help. I need create a shell script to read the mails on the SUN server, then parse the subject line and message body of each email to extract particular data so that I can pass these data fields in as application parameters to invoke a java... (4 Replies)
Discussion started by: jliharper
4 Replies

9. Shell Programming and Scripting

Mailx in shell script (KSH)

Greetings all, I'm pretty new to the use of mailx, having been using mutt most of the time. I'm interested to know how I can use mailx within a shell script to send out a formatted email with the following criterion: 1. My recipient's address is abcdef1000@gmail.com 2. The message body is... (2 Replies)
Discussion started by: rockysfr
2 Replies

10. Shell Programming and Scripting

How to use mail,mailx command in Shell Script ?

Hi.. How can i use mailx,mail command in Shell Script. Suppose i gave a condition that x value is above 25 send a mail alert to abc@rediffmail.com. How can i do this? Regards Sollin (16 Replies)
Discussion started by: sollin
16 Replies
Login or Register to Ask a Question