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:
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!!
Thanks!!! I will be monitoring this forum all day to add any info that you would need to help me out writing this script.
thank you very much for the reply. I was playing around with variables but couldnt get the if then syntax down. I imagine the "0" means that it is equalling true?
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:
There is nothing wrong with that syntax. In fact, it's preferable and simpler to directly utilize the exit status rather than complicate the code by storing it in a variable for subsequent testing (unless it's needed more than once, of course).
How is it failing? If you're using a large file, narrow it down if possible before sharing a sample of your input data. Also, copy-paste any error message and do not neglect to state what it is you're expecting (so that we can see how it deviates from your desired output).
If that code above is just a placeholder for the code that's actually failing, you should post the actual code.
...In fact, it's preferable and simpler to directly utilize the exit status rather than complicating the code by storing it in a variable for subsequent testing (unless it's needed more than once, of course).
...
If you ever worked on maintenance, you would never make a statement as above.
This is my entire code that is the latest revision before coming here for help:
Legend:
myfaxoutage.txt - file that stores the reporting for later use
outage.txt = file that contains the 1 or 0 that tells the file if an email has been sent.
newfile - file that is created in the first step (the actual status page that WGET grabs and then gets AWKed and SEDed)
Let me know if you want me to post the code to any other files.
Thanks!!
---------- Post updated at 01:19 PM ---------- Previous update was at 12:34 PM ----------
This is my current file with the changes said above:
Now, the file runs BUT it puts that the status is normal AND there is an outage in the reporting file (myfaxoutage.txt). the outage.txt has a ZERO in it to start.
---------- Post updated at 01:26 PM ---------- Previous update was at 01:19 PM ----------
Asi look more into the file, its putting both echo statements in because neither the AND statements are true so it defaults to both the ELSEs..... hmmm. I could put 4 if statements in and that would be the end of it but i know there is a more efficient way. Ill put those 4 in to get it working (need it working) and hopefully we can figure this out.
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)
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)
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)
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)
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)
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)
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)
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)
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)