Sponsored Content
Top Forums Shell Programming and Scripting Running external programs inside an if then else Post 302551985 by mrplow2k69 on Thursday 1st of September 2011 09:45:35 AM
Old 09-01-2011
Running external programs inside an if then else

Good morning,

First time poster. be gentle! Smilie

I do not know coding all that well but I can hack the hell out of example scripts! I just cant wrap my brain around this one.

Im trying to run two grep statements in the first IF statement and doing an AND between them. Something is going wrong.... Heres a sample of what I would like to do and what I have tried:

Code:
#!/bin/bash

if grep --quiet "WORD-IN-FILE" FILE-TO-CHECK && grep --quiet "WORD-IN-FILE" FILE-TO-CHECK; then

        echo both conditions are found
fi

Ultimately, im going out to a status web page, bringing down the index.html with WGET, AWKing the hell out of it then SEDing the hell out of the AWKs results and posting them to a new file. Then, I am running this file (above script) against that new file created by the previous script (which i have written already and it works well). The two GREP statements will look inside that new file created and find conditions and if those conditions are met, email me the results. I DO NOT want more than one email unless the status of the original index.html changes, then send me an email that it has changed.

Short Form: If status page shows abnormal status AND an email has not been sent yet, send an email alerting to the abnormal status and quit. Then (when the file is run again, every 15 minutes) if the status is STILL abnormal, know that you already sent an email and quit. If later checking results in NORMAL status, send an email alerting the status change and quit. Then (when the file is run every 15 minutes) is the status is still normal, know that you already sent an email and quit.

I have already written all the other programs (first prog to get status page and all the send email progs). I just need this one that figure out if an email has been sent. I have been playing around with creating a file and changing the 1 to a 0 and checking that and quitting when an email was sent but it got way too confusing!! Smilie

Thanks!!! I will be monitoring this forum all day to add any info that you would need to help me out writing this script.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

running preinstalled programs

Im using the knoppix version of linux, which is booting straight off the cd, and it shows my c drive (partiton) that has all my programs i have installed in my xp operating system. Im wondering if theres a way i can play my games like lotr return of the king, or jedi academy, in knoppox. it shows... (2 Replies)
Discussion started by: jestra
2 Replies

2. UNIX for Dummies Questions & Answers

installing/running programs.

Hey folks, i'm a total newbie at linux (only installed it yesterday) so don't be mad at me for querying this. I downloaded firefox, and unpacked the library files and binaries into /usr/lib/firefox. Now, am I correct in thinking that to run it, I need to enter the 'sh /usr/lib/firefox' command into... (4 Replies)
Discussion started by: shep
4 Replies

3. Shell Programming and Scripting

Finding The Number Of Programs That A Given User Running On A TERMINAL

How To Find The Number Of Programs That A User Running ON A GIVEN TERMINAL (4 Replies)
Discussion started by: venkata.ganesh
4 Replies

4. UNIX for Advanced & Expert Users

running X-11 programs as root

Hello, I would like to run gedit as root while logged into my regular user account. When I try to launch gedit from the command line as super user, I get this message: Gtk-WARNING **: cannot open display: Any suggestions or word arounds? It would make my life a lot simpler to edit files... (8 Replies)
Discussion started by: Allasso
8 Replies

5. UNIX for Advanced & Expert Users

calling external values inside awk command

I have a code as follows awk ' BEGIN{FS=OFS=","} { n=split($3,a1,"~") split($4,a2,"~") split($5,a3,"~") for(i=1;i<=n;i++) { print $1,$2,a1,a2,a3,date } }' file In the above code I need to add current date(date). How is this possible to call an date or a exported value... (13 Replies)
Discussion started by: tkbharani
13 Replies

6. Shell Programming and Scripting

Running external script

I do have one script which needs to be run hourly and should generates a report using an "appadmin" user. But script locates in my home directory. Whenerver i executes this script from my home directory /home/jg55555 it prompts me for the password, which is not required since im assinging the... (6 Replies)
Discussion started by: raghunsi
6 Replies

7. Shell Programming and Scripting

Running programs in perl

I am trying to run a program called GMT using perl. Cannot make to run. I have tried using exec("date"); as a test but when I use exec($try); nothing happens. #!/usr/bin/perl print "$#ARGV\n"; if ($#ARGV != 3) { print "usage: jcdplot.perl\n"; exit; } $h = $ARGV;... (1 Reply)
Discussion started by: kristinu
1 Replies

8. Shell Programming and Scripting

Running programs

I have installed a software called GMT, then writing a script that call the new programs ./example02.sh but I am getting ./example02.sh: line 20: gmtset: command not found I have done ./configure make make install (0 Replies)
Discussion started by: kristinu
0 Replies

9. Programming

Running programs from a Python script

Any idea how I can run a program from a phyton script? For example, in csh I will do $tpath/tsimplex base=$fbase data=$fdata restore=$frestore \ nxp=$nx nzp=$nz param=$param intp=$intp nlay=$nlay \ varp=$varp sigma0=$sigma maxiter=$maxiter tol=$tol \ ... (2 Replies)
Discussion started by: kristinu
2 Replies

10. Shell Programming and Scripting

Interpretation of $variables inside programs run from a script

Hi, I am running a shell script that executes a program. Inside this program, variables are also referenced using a dollar symbol, eg. $a, $thething, and the shell script is misinterpreting them as variables relevant to the shell script rather than relevant to the program run from inside the... (2 Replies)
Discussion started by: TheBigH
2 Replies
WWW::Topica::Reply(3pm) 				User Contributed Perl Documentation				   WWW::Topica::Reply(3pm)

NAME
WWW::Topica::Index - parse a single Topic mailing list index SYNOPSIS
my $index = WWW::Topic::Index->new($index_html); foreach my $message_id ($index->message_ids) { # the mail has some information and also provides a link to the reply ... my $mail = WWW::Topica::Mail->new($topica->fetch_mail($mess_id), $mess_id); # which has other information (like the un-htmled mail and the email address) ... my $reply = WWW::Topica::Reply->new($topica->fetch_reply($mail->id, $mail->eto), $mail->id, $mail->eto); } print "Next offset is ".$index->next." "; print "Previous offset is ".$index->prev." "; DESCRIPTION
Used to parse a single reply page from Topica.com's mailing list indexes. Reply pages have the body of the email (albeit quoted) and potentially a full email address. METHODS
new <page html> <message id> <eto> Takes the html of the page, the eto and the message-id and parses the html. parse <html> Parse the html to get the subject, email address and body of the email. id Get the message id eto Get the message eto email Get the email address parsed out. subject Get the email subject parsed out. body Get the email body parsed out. AUTHOR
Simon Wistow <simon@thegestalt.org> COPYRIGHT
Copyright (c) 2004, Simon Wistow perl v5.10.1 2006-01-03 WWW::Topica::Reply(3pm)
All times are GMT -4. The time now is 06:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy