Sponsored Content
Top Forums Shell Programming and Scripting Mailx Recipient and Name Script Post 302357627 by slicker on Wednesday 30th of September 2009 10:42:29 AM
Old 09-30-2009
Quote:
Originally Posted by pravin27
Hi ,
Here u go..

test_emal.txt file contains ur name and mail details.

#!/bin/sh
while read line
do
name=`echo $line | awk '{print($1)}'`
email=`echo $line | awk '{print ($2)}'`
if [ -z "$email" ]
then
echo " Hey how are u ? email id - $name"
else
echo " Hey Mr $name how r u ? email id - $email"
fi
name=''
email=''
done < test_emal.txt

Thanks for the response.

Sometimes though the name is 1, 2 or 3 fields, a name could be:

George
or
Mr Read
or
Mr George Read

So I would need to change the IFS to tab or multiple space characters perhaps?

---------- Post updated at 09:42 AM ---------- Previous update was at 08:18 AM ----------

I tried:

name=`echo $line | awk 'BEGIN { FS = "\t" } ; {print($1)}'`

and

name=`echo $line | awk -F"\t" '{print($1)}'`


These work on the command line but not in the script.

Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unknown recipient when using metasend

Hi, We use metasend to send e-mail from our app. This works fine with most kinds of mail, for example plain text, HTML with images and mail with attachments. But we still have one problem: If the to-address is misspelled, then still everything seems to be fine. We don't get any message back... (4 Replies)
Discussion started by: sjohnsen
4 Replies

2. Shell Programming and Scripting

Creating a multi-recipient email script

Well, I'm fairly new to shell scripting, so please excuse my newbieness :) I was wondering if it was possible to create a shell script that retrieves a list of recipients in a list_file and sends a message out all at once? An example of a list file would look similar to this: $ cat... (2 Replies)
Discussion started by: TheSunTheSea
2 Replies

3. UNIX for Dummies Questions & Answers

sendmail recipient issue

I can send external emails from one of my unix boxes but can no longer send internal emails, i have used mailx -v to see what's going on and it seems there is a problem with the RCPT TO part of the log It seems to add name@nsmail1.mydmn.gov.uk When it should be just name@mydmn.gov.uk The... (1 Reply)
Discussion started by: supadid
1 Replies

4. UNIX for Dummies Questions & Answers

mailx recipient restriction

maybe a simple question, but i've looked around and not been able to find anything. is there a restriction on how many recipients can be used in a single mailx command? whether it's a numeric restriction or a size restriction (like 256k for the whole recipient parameter). thanks a lot. (6 Replies)
Discussion started by: chris32680
6 Replies

5. UNIX for Dummies Questions & Answers

Configure Recipient Restrictions in Postfix

Hi all We need to block our users sending emails to specific email addresses. At the moment, recipient restrictions is not enabled in our Postfix relay server so all messages submitted from our Exchange server are accepted and relayed. See entries in our main.cf file: ### Recipient... (0 Replies)
Discussion started by: wbdevilliers
0 Replies

6. Shell Programming and Scripting

Send email recipient based on filename

Hi All can someone help please create a bash script. Here's a scenario: 1. I have a directory where it's a destination for scanned documents. e.g. /dest/scan 2. The filename is in the form IDNumber_Category. e.g. 123456_notes.pdf 3. The first part of the script is to rename the... (1 Reply)
Discussion started by: aemestech
1 Replies

7. Shell Programming and Scripting

sendmail script throwing an error "No recipient addresses found in header"

Hi, I am using following code to send an e-mail with attachment and body. echo "To: user1@mail.com,user2@mail.com" > mail.tmp echo "Cc: user3@mail.com,user4@mail.com" >> mail.tmp echo "From: group@mail.com" >> mail.tmp echo "Subject: my report" >> mail.tmp echo "please see as attached"... (6 Replies)
Discussion started by: vivek_damodaran
6 Replies

8. Programming

Mailx recipient from mysql database

Dear All, Can I make Mailx to read recipient address from a mysql database? I already tried emailing with bash script: SUBJECT="TEST" export EMAIL_ADDRESS=`mysql -uroot -pabcde smsd -e "SELECT email FROM recipient"` mysql -uroot -pabcde smsd -e "SELECT ID, SenderName, Body FROM inbox" |... (2 Replies)
Discussion started by: jazzyzha
2 Replies

9. Shell Programming and Scripting

Mailx recipient from mysql database

Dear All, Can I make Mailx to read recipient address from a mysql database? I already tried emailing with bash script: SUBJECT="TEST" export EMAIL_ADDRESS=`mysql -uroot -pabcde smsd -e "SELECT email FROM recipient"` mysql -uroot -pabcde smsd -e "SELECT ID, SenderName, Body FROM inbox" |... (14 Replies)
Discussion started by: jazzyzha
14 Replies

10. UNIX for Dummies Questions & Answers

Emails sent from Linux server are rejected by recipient

Hello i have this longterm issue which im unable to solve, i think this is quite simple issue, i hope you may know the cause It is on CentOS Redhat server with qmail installed. # service qmail status # service qmail start Starting Qmail: # ps aux | grep mail qmails 1688 0.0 0.0 ... (1 Reply)
Discussion started by: postcd
1 Replies
Locale::Script(3pm)					 Perl Programmers Reference Guide				       Locale::Script(3pm)

NAME
Locale::Script - standard codes for script identification SYNOPSIS
use Locale::Script; $script = code2script('phnx'); # 'Phoenician' $code = script2code('Phoenician'); # 'Phnx' $code = script2code('Phoenician', LOCALE_CODE_NUMERIC); # 115 @codes = all_script_codes(); @scripts = all_script_names(); DESCRIPTION
The "Locale::Script" module provides access to standards codes used for identifying scripts, such as those defined in ISO 15924. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 15924 four-letter codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying scripts. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $script = code2script('phnx','alpha'); $script = code2script('phnx',LOCALE_SCRIPT_ALPHA); The codesets currently supported are: alpha, LOCALE_SCRIPT_ALPHA This is a set of four-letter (capitalized) codes from ISO 15924 such as 'Phnx' for Phoenician. It also includes additions to this set included in the IANA language registry. The Zxxx, Zyyy, and Zzzz codes are not used. This is the default code set. num, LOCALE_SCRIPT_NUMERIC This is a set of three-digit numeric codes from ISO 15924 such as 115 for Phoenician. ROUTINES
code2script ( CODE [,CODESET] ) script2code ( NAME [,CODESET] ) script_code2code ( CODE ,CODESET ,CODESET2 ) all_script_codes ( [CODESET] ) all_script_names ( [CODESET] ) Locale::Script::rename_script ( CODE ,NEW_NAME [,CODESET] ) Locale::Script::add_script ( CODE ,NAME [,CODESET] ) Locale::Script::delete_script ( CODE [,CODESET] ) Locale::Script::add_script_alias ( NAME ,NEW_NAME ) Locale::Script::delete_script_alias ( NAME ) Locale::Script::rename_script_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Script::add_script_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Script::delete_script_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.unicode.org/iso15924/ Home page for ISO 15924. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 1997-2001 Canon Research Centre Europe (CRE). Copyright (c) 2001-2010 Neil Bowers Copyright (c) 2010-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Script(3pm)
All times are GMT -4. The time now is 11:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy