Mail from unix box


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mail from unix box
# 1  
Old 08-14-2006
Mail from unix box

I am executing the below script from unix box

If row count is zero the mail should not set to the client

The problem is, if row count is zero the mail is going to the client
(what is wrong in the script)


SET HEAD OFF FEED OFF PAGES 0
Select count(*) as change_count from DBG_INITIATIVES_CHANGE;"

change_count=${output}

echo $change_count

if [ ${change_count} > 0 ]; then

mailx -s aaa@yahoo.com

EOF

exit 1

fi

exit 0
# 2  
Old 08-14-2006
Can you modify your script a bit....

Code:
X=`sqlplus -s user/pwwd@domain<<eof
set serveroutput on;
set heading off;
DECLARE
change_count number;
BEGIN
Select count(*) into change_count from DBG_INITIATIVES_CHANGE;
dbms_output.put_line(change_count);
END;
/
EXIT;
eof`
if [ $X -gt 0 ]
then
#put ur mail command here
else
echo "count is zero"
fi

# 3  
Old 08-14-2006
Mail from unix box

This is my output
SQL> Select count(*) as change_count from DBG_INITIATIVES_CHANGE;

CHANGE_COUNT
------------
0

I have to check CHANGE_COUNT is 0 If it is 0 then I should not send mail
# 4  
Old 08-14-2006
Yes the above script is doing what you say it should it will login to sqlplus execute the query and thru dbms output package X will have value of change_count and it will send mail if change_count is greater then zero.

sqlplus -s user/pwwd@domain<<eof in this line give your user name password and domain.run the below code as shell script.

Code:
X=`sqlplus -s user/pwwd@domain<<eof
set serveroutput on;
set heading off;
DECLARE
change_count number;
BEGIN
Select count(*) into change_count from DBG_INITIATIVES_CHANGE;
dbms_output.put_line(change_count);
END;
/
EXIT;
eof`
if [ $X -gt 0 ]
then
mailx -s "count is greater than zero" abcd@xyz.com
else
echo "count is zero"
fi

# 5  
Old 08-14-2006
Mail from unix box

I have to grep the output If output is zero(0) I should not send mail

If ouput is > 0 the mail should send to client

You are using plsql scripting

(My problem is to restrict the mail only)
# 6  
Old 08-14-2006
The same without PL/SQL :
Code:
X=`sqlplus -s user/pwwd@domain<<eof
SET HEAD OFF FEED OFF PAGES 0
Select count(*) from DBG_INITIATIVES_CHANGE;
eof`
if [ $X -gt 0 ]
then
mailx -s "count is greater than zero" abcd@xyz.com
else
echo "count is zero"
fi

Jean-Pierre.
# 7  
Old 08-15-2006
Hi

Can anyone tell me what does following line signify :

X=`sqlplus -s user/pwwd@domain<<eof


Thanks & Regards

Pankaj
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX mail box

Currrently I am not able to send/receive any emails to email id. I believe my mail box is full in server. could you please let me kknow to clear the emails in the unix server. (2 Replies)
Discussion started by: ramkumar15
2 Replies

2. Shell Programming and Scripting

Clean up UNIX mail box using script

Hi, I would like to clean up by unix mail mail box thru some script command.. I do know how to delete from mail box ... e.g. $ mail ? d* ? quit But I need to clean up thru some command which I can use in my script before sending any email.. Thanks in advance! (1 Reply)
Discussion started by: pareshkp
1 Replies

3. Solaris

Mail system Configuration issue on UNIX box

Hi, I wanted to configure a mail system on my UNIX box. For that I read a document Sun Internet Mail Server 3.5 Advanced Installation Guide: Contents which is actually quite useful document but I am not sure from where can I bring patch? Is this patch will come in any CD form which I need to run... (1 Reply)
Discussion started by: Dhruvak
1 Replies

4. Shell Programming and Scripting

ftp file starting with particular name on Windows box to Unix box using shell script

Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the... (2 Replies)
Discussion started by: vijayb4u83
2 Replies

5. Shell Programming and Scripting

Unix Mail Box

Hi Friends, I'm new to Unix. I have a fbackup step like /bin/nice /etc/fbackup -f /dev/rmt/0m -i / -I /opt/monitrol/tmp/Index.full 2 > /var/adm/error.log the errors for this step is redirected to a log file. How can I make to trigger mails when error occurs. Please suggest. Thanks in... (4 Replies)
Discussion started by: avik.nandi
4 Replies

6. UNIX for Dummies Questions & Answers

unix script to check if rsh to box and send status mail

rshstatus=`rsh -n lilo /db/p2/oracle/names9208/restart_names.sh` if $rshstatus <>0 then errstatus=1 mailx -s "xirsol8dr" ordba@xxx.com >> $log_dr else if errstatus=0 echo "status to xirsol8dr successful" can anyone provide if this is t he correct way to do this or is there a better way? (1 Reply)
Discussion started by: bpm12
1 Replies

7. Shell Programming and Scripting

how to compare all files in one unix box has been to copied to another unix box

Hi our unix admin has copied all files from one unix box to new unix box. We just need to confirm that all the file systems are copied properly. How to validate. (9 Replies)
Discussion started by: sravanreddym
9 Replies

8. UNIX for Dummies Questions & Answers

Receive e-mail on unix box

Hi, I am not sure if it is a good question or not. Is there a unix utility which can be configured with exchange server and then receive e-mails? Thanks! (4 Replies)
Discussion started by: DejaVu
4 Replies

9. UNIX for Dummies Questions & Answers

Running UNIX commands remotely in Windows box from Unix box – avoid entering password

I am able to run the UNIX commands in a Windows box from a UNIX box through "SSH" functionality. But whenever the SSH connection is established between UNIX and Windows, password for windows box is being asked. Is there a way to avoid asking password whenever the SSH connection is made? Can I... (1 Reply)
Discussion started by: D.kalpana
1 Replies

10. UNIX for Advanced & Expert Users

VPN client (windows Box),and Server (Unix Box)

If I want to access unix box via VPN tunnel,from windows box. What sould I configure on the windows client PC, and what should I enable on the Unix Server box ? I am using Solaris V10 intel platform, and I am using windows XP, and 2003 for client (0 Replies)
Discussion started by: zillah
0 Replies
Login or Register to Ask a Question