Condition in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Condition in script
# 1  
Old 05-16-2010
Condition in script

Hi all,

I am writing a script (.sh) which takes backup of database, zip it ftp to remote server and finally mail me to notify. So far this all has been done, however, now I am looking to add notification over each step. Means if any step is failed, then I should get an email and if all goes well, then I should get a mail that step 1, 2 and 3 are done successfully.

example:
Code:
#!/bin/sh
#
# step 1
backup database 
if(step 1 = true){
   do nothing;
}
else{
  mail admin and stop further execution
}

#step 2
gzip database dump
if(step 2= true){
   do nothing;
}
else{
  mail admin and stop further execution
}

#step 3
ftp dump to remoteServer
if(step 3 = true){
   do nothing;
}
else{
  mail admin and stop further execution
}

#step 4
mail administrator that all steps GOOD.



Bye,
Viki.
# 2  
Old 05-16-2010
you can check exit status of each command sequence
# 3  
Old 05-16-2010
This post looks like an early design concept or a homework question?

Please post the existing working script, highlighting those checkpoints which need an additional email progress report.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Condition in bash script

I want get from user and pass these parameters to bash script. script should copy files in user home directory. FYI: each file might be exist or not, might be one of them exist or four of them. Here is my script, it always copy file1 and seems only one of them execute! #!/bin/bash for... (6 Replies)
Discussion started by: indeed_1
6 Replies

2. Shell Programming and Scripting

If condition shell script beginner

Hi all I have the folloing process that needs checking often: ps -ef | grep ih bscsrtx 206 15901 0 11:28:10 pts/6 0:00 fih -r4 bscsrtx 218 15901 0 11:28:27 pts/6 0:01 aih bscsrtx 29763 15901 4 11:27:16 pts/6 0:59 rdh -prih root 429 27268 0 11:30:15 pts/td ... (13 Replies)
Discussion started by: fretagi
13 Replies

3. Shell Programming and Scripting

Need Help to add Condition in Shell Script..

Hi Team, I m very new to shell scripting , i want to add following condition in my script . Can anybody help me. There are three port in My node "$port" port_A port_B port_C I Want to add following Conditions in my script. If Node is connected to port_A and port_B script... (10 Replies)
Discussion started by: Ganesh Mankar
10 Replies

4. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

5. UNIX for Dummies Questions & Answers

While condition in shell script

while do if ;then read driverName else driverName="" fi done can anyone please explain what exactly is happening on 1st line...is it like the conditions being ORed...I have no clue about this. (4 Replies)
Discussion started by: rtagarra
4 Replies

6. Shell Programming and Scripting

Script with variable and condition

Hello newbies question... I just need a script able to launch a command when a condition is matched : #!/bin/ksh SIZ = 'cat /nurp/control.lst|wc -l' if test "$SIZ" -gt 0 then echo 1 else echo 2 fi but I receive errors messages ./t2: SIZ: not found 2 whats wrong ? (5 Replies)
Discussion started by: vdurieu
5 Replies

7. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

8. Shell Programming and Scripting

Script printing else condition

Please help what is wrong in below script. It is printing else also, else echo "DATABASE NOT RUNNING :${i} ================================================= #!/usr/bin/ksh set -A DBS $(cat /etc/oratab | grep ":Y" | awk -F : '{print $1}') set -A RDBS $(ps -ef | grep -i pmon | grep... (3 Replies)
Discussion started by: allwin
3 Replies

9. Shell Programming and Scripting

Help with shell script to check the condition.

:) Hi, I want to script for this scenerio, OSR Settings Scenario : We are looking to find all the *.a files from the following locations in the filesystem of a server. OSR Directories /etc /bin /usr/bin /usr/sbin /var/adm These *.a files should have the permissions on... (12 Replies)
Discussion started by: sakthilinux
12 Replies

10. Shell Programming and Scripting

OR'ing condition in script

Hi, I have the following requirement. I am building a product on linux. The final build executables and libraries are all in different directories. I am writing a release script to collect all these final build items into a directory in /home/$USER/release. I have the following condition: ... (9 Replies)
Discussion started by: vino
9 Replies
Login or Register to Ask a Question