How to display HOSTNAME in sendmail?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to display HOSTNAME in sendmail?
# 1  
Old 04-24-2017
Hammer & Screwdriver How to display HOSTNAME in sendmail?

I have two issues with my script one of which i would like to discuss here.

Its my compulsion to use sendmail.

My sample script

Code:
#!/bin/bash

{
        print 'From: Prod@`hostname`.mycomp.com'
        print 'To: me@mycomp.com'
        print 'MIME-Version: 1.0'
        print 'Content-Type: text/html'
        print 'Subject: Usage Report'
        print ''
        print '<html>'
        print '<body>'
        print '<p>Today Usage Report for Server</p>'

        print '</body>'
        print '</html>'
} | /usr/sbin/sendmail -t

Wehn i run the above with debug mode i see that the hostname is not substituted in the From of the email.

i also tried the below in vain

Code:
print 'From: Prod@$hostname.mycomp.com'

Code:
uname -a
SunOS myhost 5.11 11.3 sun4u sparc SUNW,SPARC-Enterprise

Can you please suggest something that works with both bash and ksh shells ?
# 2  
Old 04-24-2017
You need to use double quotes instead of single quotes. Also, print is not bash syntax but ksh syntax.
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 04-24-2017
Hammer & Screwdriver

Quote:
Originally Posted by Scrutinizer
You need to use double quotes instead of single quotes. Also, print is not bash syntax but ksh syntax.
Thank you for the help. I will open a new thread for the second issue.

Last edited by mohtashims; 04-24-2017 at 07:02 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Clarifying sendmail configuration - sendmail-client offline

Hi all, I have read about sendmail running as 2 separate process. 1 as a MSP, and the other as the real daemon or MTA. In my current configuration, the sendmail-client is disabled. Both submit.cf and sendmail.cf are left as default untouch I do not specified any mailhost... (3 Replies)
Discussion started by: javanoob
3 Replies

2. UNIX for Advanced & Expert Users

Hostname -f hostname: Unknown host

deleted (0 Replies)
Discussion started by: hce
0 Replies

3. UNIX for Advanced & Expert Users

Sendmail questions, SCO 5.0.6 sendmail 8.11.0

I am running SCO 5.0.6 and using sendmail 8.11.0 and having issues with smtp authentication. When trying to send mail the following message will kick back. (reason: 530 5.7.1 Authentication required) 530 5.7.1 Authentication required Not sure what needs to be tweeked in sendmail.cf but I... (1 Reply)
Discussion started by: ziggy6
1 Replies

4. UNIX for Dummies Questions & Answers

nLocal sendmail issues when hostname not set in official domain name

Hi, I'm having issues with sendmail when I try to send host to host mail. I've had to change the "my official domain name" line to mycompany.com to get the mails through the external spam filter, when a mail was sent with hostname.mycompany.com it was blocked. I had to change the Dj macro... (0 Replies)
Discussion started by: elcounto
0 Replies

5. UNIX for Advanced & Expert Users

AIX - Sendmail - add hostname to subject of outgoing mail

Hello, I'm configuring sendmail on an AIX 7.1 server (bos.net.tcp.client 7.1.1.15). I've gotten sendmail to send mail through our Novell GroupWise server, so that mail from a user on the server appears to come from their GroupWise account, and replies to the email would go to their GroupWise... (0 Replies)
Discussion started by: eyebeam
0 Replies

6. Solaris

Classic: sendmail[pid]: My unqualified host name (hostname) unknown

Hi all, I'd like to disable sendmail permanently on my "new" 220R with freshly installed SunOS 5.10 because it prints annoying messages to the system console. Also I'm interested in how to fix the actual problem with unqualified host name. My unqualified host name (hostname) unknown; sleeping... (2 Replies)
Discussion started by: pseudocoder
2 Replies

7. Emergency UNIX and Linux Support

HP UX - ILO Console hostname different than Machine Hostname...

Hi All, So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says: It should say: What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies

8. Solaris

How to display hostname in command prompt

Anyone know How to configure solaris 8 to display hostname in command prompt , everytime when you open a terminal screen . (3 Replies)
Discussion started by: civic2005
3 Replies

9. UNIX for Dummies Questions & Answers

Solaris - unknown hostname - how can I change hostname?

Hello, I am new to Solaris. I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)
Discussion started by: XNOR
1 Replies
Login or Register to Ask a Question