Sponsored Content
Top Forums Shell Programming and Scripting Smarter conditional script with Table Post 302827073 by jazzyzha on Thursday 27th of June 2013 10:00:05 PM
Old 06-27-2013
Do you mean like this?

Code:
GRP_email_subject=$(mysql -uroot -p123456 smsd -e "SELECT email_subject FROM kontak_group")
GRP_email_address_list=$(mysql -uroot -p123456 smsd -e "SELECT email_group FROM kontak_group")

CNT=0    # use to check if any of the group errors are found
for GRP in $(< file.txt)
do
     echo $CHECKER | grep $GRP > /dev/null
     if [ $? -eq 0 ]
     then
           CNT=$(($CNT + 1))
           case $GRP in 
           ADM)message=$message2;;
           IRC) message=$message2;;
	   PTM) message=$message2;;
            BS) message=$message2;;
           esac
#          eval SUBJECT=\$${GRP}subject
	   SUBJECT=$GRP_email_subject
#          eval ADDLIST=\$${GRP}emails
	   ADDLIST=$GRP_email_address_list
           for EMAIL_ADDRESS in $ADDLIST
           do
	        echo $message | mailx -s "$SUBJECT" -a From:$SENDER $EMAIL_ADDRESS
	   done
           echo " email sent to $GRP contacts"
           break
    fi
done

if [ $CNT -eq 0 ]
then
      $SPAM
fi

But still the script using this:
Code:
          ADM)message=$message2;;
           IRC) message=$message2;;
	   PTM) message=$message2;;
            BS) message=$message2;;

and still using .txt files.

Smilie
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Confusion over a small conditional script

Hi, I was going through a file containing hundreds of lines of codes having conditional statement written as: log() { echo $@ } num=$(/usr/bin/rsh <one_machine> -l root 'ls -d /home/user/db* 2> /dev/null' | wc -w) (( num > 0 )) && log "db info:" so,if here the return value(stored in... (2 Replies)
Discussion started by: amit4g
2 Replies

2. Shell Programming and Scripting

Conditional Date Script

I am learning Unix for the first time. I am playing around with my default profile file to add some script in the KSH. The time format is GMT and I am in eastern time zone. I am trying to script some greetings based upon the time of day using the IF/ELIF conditions. I am getting errors. I have... (2 Replies)
Discussion started by: cpd259
2 Replies

3. Shell Programming and Scripting

unix script for conditional execution

Below is my shell script. I am trying to execute two different BTEQ scripts depending on the day of the week. So on a saturday I will execute a certain BTEQ script and on other weekdays I will run the other script. #!/bin/ksh dt=`date +"%a"` if then bteq > final_output <<- EOF .run... (3 Replies)
Discussion started by: Mihirjani
3 Replies

4. Shell Programming and Scripting

Conditional Execution of a Script.

I have a unix shell script Test.sh more Test.sh echo "Calling dbquery1.sh...." ./dbquery1.sh echo "Calling dbquery2.sh...." ./dbquery2.sh more dbquery1.sh sqlplus -s user1/password1@DB_SID @/tmp/storedprocedures/Hello.rcp I run Test.sh However, I do not want dbquery2.sh to be... (3 Replies)
Discussion started by: mohtashims
3 Replies

5. Shell Programming and Scripting

Help with conditional clauses for script output

Hello. I am new this site as well as new to shell scripting and this is my first form... Please help me with the following shell script. I am executing a shell script to run every 15 min (scheduled in cronjob) and it gives an output in an output file which is e-mailed. CONCCOUNT=`cat... (1 Reply)
Discussion started by: Jamessteevens
1 Replies

6. UNIX for Dummies Questions & Answers

Conditional Script

Hi, I have a script file which has some simple commands. I want these commands to be executed based on the input. Ia m good with IF statement also. At the end it has to be based on incoming value. Example CASE 1 : Execute some commands where Input value as 1 CASE 2 : Execute... (5 Replies)
Discussion started by: vrupatel
5 Replies

7. Shell Programming and Scripting

Smarter way to read $1 $2 in php

Hello, I am running under ubuntu14.04 with php5. When I run below php, it creates a token, then adds axaxax and bxbxbx into pc database, and at last, kills created token. What I am trying to do is to add userid and password read from a file. I do not wish to enter username and password manually.... (3 Replies)
Discussion started by: baris35
3 Replies
Email::Send(3pm)					User Contributed Perl Documentation					  Email::Send(3pm)

NAME
Email::Send - Simply Sending Email WAIT! ACHTUNG! Email::Send is going away... well, not really going away, but it's being officially marked "out of favor." It has API design problems that make it hard to usefully extend and rather than try to deprecate features and slowly ease in a new interface, we've released Email::Sender which fixes these problems and others. As of today, 2008-12-19, Email::Sender is young, but it's fairly well-tested. Please consider using it instead for any new work. SYNOPSIS
use Email::Send; my $message = <<'__MESSAGE__'; To: recipient@example.com From: sender@example.com Subject: Hello there folks How are you? Enjoy! __MESSAGE__ my $sender = Email::Send->new({mailer => 'SMTP'}); $sender->mailer_args([Host => 'smtp.example.com']); $sender->send($message); # more complex my $bulk = Email::Send->new; for ( qw[SMTP Sendmail Qmail] ) { $bulk->mailer($_) and last if $bulk->mailer_available($_); } $bulk->message_modifier(sub { my ($sender, $message, $to) = @_; $message->header_set(To => qq[$to@geeknest.com]) }); my @to = qw[casey chastity evelina casey_jr marshall]; my $rv = $bulk->send($message, $_) for @to; DESCRIPTION
This module provides a very simple, very clean, very specific interface to multiple Email mailers. The goal of this software is to be small and simple, easy to use, and easy to extend. Constructors new my $sender = Email::Send->new({ mailer => 'NNTP', mailer_args => [ Host => 'nntp.example.com' ], }); Create a new mailer object. This method can take parameters for any of the data properties of this module. Those data properties, which have their own accessors, are listed under "Properties". Properties mailer The mailing system you'd like to use for sending messages with this object. This is not defined by default. If you don't specify a mailer, all available plugins will be tried when the "send" method is called until one succeeds. mailer_args Arguments passed into the mailing system you're using. message_modifier If defined, this callback is invoked every time the "send" method is called on an object. The mailer object will be passed as the first argument. Second, the actual "Email::Simple" object for a message will be passed. Finally, any additional arguments passed to "send" will be passed to this method in the order they were received. This is useful if you are sending in bulk. METHODS send my $result = $sender->send($message, @modifier_args); Send a message using the predetermined mailer and mailer arguments. If you have defined a "message_modifier" it will be called prior to sending. The first argument you pass to send is an email message. It must be in some format that "Email::Abstract" can understand. If you don't have "Email::Abstract" installed then sending as plain text or an "Email::Simple" object will do. Any remaining arguments will be passed directly into your defined "message_modifier". all_mailers my @available = $sender->all_mailers; Returns a list of availabe mailers. These are mailers that are installed on your computer and register themselves as available. mailer_available # is SMTP over SSL avaialble? $sender->mailer('SMTP') if $sender->mailer_available('SMTP', ssl => 1); Given the name of a mailer, such as "SMTP", determine if it is available. Any additional arguments passed to this method are passed directly to the "is_available" method of the mailer being queried. Writing Mailers package Email::Send::Example; sub is_available { eval { use Net::Example } } sub send { my ($class, $message, @args) = @_; use Net::Example; Net::Example->do_it($message) or return; } 1; Writing new mailers is very simple. If you want to use a short name when calling "send", name your mailer under the "Email::Send" namespace. If you don't, the full name will have to be used. A mailer only needs to implement a single function, "send". It will be called from "Email::Send" exactly like this. Your::Sending::Package->send($message, @args); $message is an Email::Simple object, @args are the extra arguments passed into "Email::Send::send". Here's an example of a mailer that sends email to a URL. package Email::Send::HTTP::Post; use strict; use vars qw[$AGENT $URL $FIELD]; use Return::Value; sub is_available { eval { use LWP::UserAgent } } sub send { my ($class, $message, @args); require LWP::UserAgent; if ( @args ) { my ($URL, $FIELD) = @args; $AGENT = LWP::UserAgent->new; } return failure "Can't send to URL if no URL and field are named" unless $URL && $FIELD; $AGENT->post($URL => { $FIELD => $message->as_string }); return success; } 1; This example will keep a UserAgent singleton unless new arguments are passed to "send". It is used by calling "Email::Send::send". my $sender = Email::Send->new({ mailer => 'HTTP::Post' }); $sender->mailer_args([ 'http://example.com/incoming', 'message' ]); $sender->send($message); $sender->send($message2); # uses saved $URL and $FIELD SEE ALSO
Email::Simple, Email::Abstract, Email::Send::IO, Email::Send::NNTP, Email::Send::Qmail, Email::Send::SMTP, Email::Send::Sendmail, perl. PERL EMAIL PROJECT
This module is maintained by the Perl Email Project. <http://emailproject.perl.org/wiki/Email::Send> AUTHOR
Current maintainer: Ricardo SIGNES, <rjbs@cpan.org>. Original author: Casey West, <casey@geeknest.com>. COPYRIGHT
Copyright (c) 2005 Casey West. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2011-08-31 Email::Send(3pm)
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy