I have to wrote a script where I am able to echo a result of an SQL script, however I want to be able to send an email to myself when it is more than 0 (so whenever a value is returned) is this possible?
I tried one way from looking on the web but this didn't work, I have added my script below
The count works fine and returns what is expected
Any help will be much appreciated
Many Thanks
Moderator's Comments:
Please use CODE tags as required by forum rules!
For your benefit, I replaced your clear text e-mail-address with a dummy one.
Last edited by RudiC; 03-09-2017 at 10:23 AM..
Reason: Added CODE tags.
You will of course have to edit the code I provided so that it has your own variable defitions, and you'll need to change the line that sends the mail to have your own e-mail address in it.
But as you can see from my own run of the script which I included as sample output, it did run, and sent me an e-mail which I was able to read.
What output did you get from the script ? What type of system are you running it on, and what shell are you using ? For reference, my own system is running Linux, specifically Ubuntu 16.04 LTS x86_64, and this script is set up to use Bash as the shell.
On top of what drysdalk said, you might want to reduce resource consumption by running the psql query just once. One option would be to use "here strings" provided by recent shells (ksh, bash):
I was meaning what is the nature of the system that's running the script ? What you're running on your own PC isn't really relevant. Is it Linux/Solaris/AIX/etc, and what shell are you using ? If you copy-and-paste in its entirety the sample code I gave you into a fresh script (with the only change being the e-mail address), does that at least run and send you an e-mail ?
I am running the gaussian program on UNIX with bash and I want to form a script that will email me once the output life terminates either "normal termination" or "false" I just started learning this last week so could you let me know how to go about this.:b: (13 Replies)
This is my first time writing a script and Im having some trouble,
Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage
I tried grep
Obviosly that hasnt worked,
Any... (8 Replies)
Hi all,
I have a task on my plate which is of high priority.
I need an automated email alert that checks FTP notices subdirectory on a daily basis and forwards any word files to a group of people. This word files gets created whenever there is an issue with FTP connectivity.
Please help...... (1 Reply)
Hello,
I want a script that will scan the file /etc/httpd/conf/httpd.conf and the folder /etc/httpd/libexec/
-bash-2.05b# grep mod_r /etc/httpd/conf/httpd.conf
LoadModule rewrite_module libexec/mod_rewrite.so
AddModule mod_rewrite.c
-bash-2.05b#
-bash-2.05b# find... (4 Replies)
I need to code a script, which will run via cron, every 30 minutes.
The script will read a file containing a date&time and number (which represents disk space). The file gets appended to every 30 minutes. Here's a sample of the file:
CPU 1:04/25/02 1:00 am:1972554
CPU 1:04/25/02 1:30... (1 Reply)