nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

syntax for mail

This is a discussion on syntax for mail within the Shell scripting forums, part of the Development/Scripting category; Hi , I am trying to write a script , in which I want to use if else statement.I have ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-05-2008, 04:30 AM
Member
User
 
Join Date: Jan 2008
My distro: Debian/Redhat
Posts: 39
Rep Power: 0
pansarevai is on a distinguished road
Default syntax for mail

Hi ,

I am trying to write a script , in which I want to use if else statement.I have check both the parts but to connectiing them I want to add a syntax in between. My script is as follows , kindly suggest me the correct syntax for it.

if [ mailfrom = *@domain.com ]
then
...
..

else
...

What syntax I can use here so as to complete this script mailfrom = *@domain.com.

Regards
Vaibhav
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-11-2008, 01:12 PM
agn agn is offline
Member
User
 
Join Date: Feb 2008
My distro: OpenBSD/FreeBSD/Debian/Fedora/RHEL
Posts: 69
Rep Power: 1
agn is on a distinguished road
Default

Your question isn't clear. But from what I understood this maybe what you're looking for

Code:
if [ $mailfrom = "domain.com" ]
then
    # do something
else
   # do something else
fi
To get the domain part you may do something like this

Code:
mailfrom=$(echo user@domain.com | cut -d '@' -f 2)
Hope this helps.
Reply With Quote
  #3 (permalink)  
Old 02-12-2008, 02:13 AM
Member
User
 
Join Date: Jan 2008
My distro: Debian/Redhat
Posts: 39
Rep Power: 0
pansarevai is on a distinguished road
Default

Thnx a lot . I think what you suggest should work. I will work out with this syntax and will check.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +5.5. The time now is 11:05 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36