System Administration
Showing results for 
Search instead for 
Do you mean 

Script issue moving from HPUX to Linux for mail

SOLVED
Go to Solution
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
1 ACCEPTED SOLUTIONS
Trusted Contributor Trusted Contributor

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.
7 REPLIES
Honored Contributor 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".
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.
Trusted Contributor Trusted Contributor

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.
Advisor

Re: Script issue moving from HPUX to Linux for mail

Thanks I believe that would would. I will give it a try.
Acclaimed Contributor 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
Advisor

Re: Script issue moving from HPUX to Linux for mail

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

Re: Script issue moving from HPUX to Linux for mail

Dennis provided the information I was looking for.