Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Script issue moving from HPUX to Linux for mail

SOLVED
Go to solution
ECUse
Advisor

Script issue moving from HPUX to Linux for mail

Hi,

I have a script that I am migrating from a HPUX system to a REDHAT 5.3 system. I am trying to insert a file as a text attachment to a message. It works in HPUX, but not in Linux. Here it is....

HPUX:
mailx -s "test" bob@aol.com << EOF
This is my e-mail text message.

~r /home/bob/log/logfile
EOF

Linux:
mail -s "test" bob@aol.com << EOF
This is my e-mail text message.

~r /home/bob/log/logfile
EOF

The problem is the ~r is seen as text in the e-mail message and not executing the function in the script under linux.

Any ideas.

Thx
7 REPLIES
Steven Schweda
Honored Contributor

Re: Script issue moving from HPUX to Linux for mail

Apparently "mailx" on HP-UX and "mail" on
your GNU/Linux system are different programs.

> Any ideas.

Yes?

If nothing else, instead of expecting "mailx"
to do all the work, you could use "cat" (or
something) to combine your message text with
the contents of that "~r" file, and send the
result through "mail".
ECUse
Advisor

Re: Script issue moving from HPUX to Linux for mail

I have implemented the work around you have suggest. I know the ~r option works in Linux. It's just bugging me that I can't get it to work as it did in HPUX. If I manually type the message and add the ~r filename. It works. Just using the redirect text option it doesn't. I am wondering if there is an escape character to allow it to execute the option instead of reading it as text.
Randy Jones_3
Trusted Contributor
Solution

Re: Script issue moving from HPUX to Linux for mail

mailx and mail are different, and the tilde trick is specific to mailx.

If you don't have /bin/mailx present on your 5.3 system, install the Linux Standard Base RPM ("yum install redhat-lsb") and several things will probably be more in line with scripts you wrote for HP-UX.
ECUse
Advisor

Re: Script issue moving from HPUX to Linux for mail

Thanks I believe that would would. I will give it a try.
Dennis Handly
Acclaimed Contributor

Re: Script issue moving from HPUX to Linux for mail

If you are using a real shell you should be able to get the here document to read that file:
mail -s "test" bob@aol.com << EOF
This is my e-mail text message.

$(< /home/bob/log/logfile)
EOF
Highlighted
ECUse
Advisor

Re: Script issue moving from HPUX to Linux for mail

That works perfectly Dennis. Dang, I never looked at that thread until now.
ECUse
Advisor

Re: Script issue moving from HPUX to Linux for mail

Dennis provided the information I was looking for.