Operating System - Linux
1752793 Members
5940 Online
108789 Solutions
New Discussion юеВ

Re: 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 7
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
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.