Is this possible?
I know your able to use prewritten scripts like so:
Code:
mysql db_name < text_file
but what if the sql statement needs other variables in order to be useful.
Let me explain.
I've written a script that searches a directory for *.%17 files. These are text files output from our archaic back office software. This software was written before the days of email addresses so doesn't unerstand them.
If the script finds a %17 file it runs a line:
Code:
luser=`sed '2!d' $file`
which scans the second line of the file for the username
I have another file set up that looks like this called emap
Code:
AJR angela@domain.com
AM annem@domain.com
AR angel@domain.com
AR2 angel@domain.com
AW andrew@domain.com
BB blaize@domain.com
I then run a line that goes:
Code:
senderemail=`grep -w ${luser:0:8} /path/to/emap`
I can then use
for my email address which I can then use with mutt. Hey presto, an email spooler.
It works but is very cumbersome and I could do with more fields with more info for each user to add extra functionality.
I would to use bash to say something along the lines of:
email=`select email from database where $luser = AJR`
or
phone=`select phoneno from database where $luser = AJR`
Is this possible, because it would be great.
Thanks
Ed