Re: Script issue moving from HPUX to Linux for mail (74 Views)
Reply
Advisor
ECUse
Posts: 31
Registered: ‎04-14-1997
Message 1 of 8 (74 Views)
Accepted Solution

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
Honored Contributor
Steven Schweda
Posts: 9,096
Registered: ‎02-23-2005
Message 2 of 8 (74 Views)

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
ECUse
Posts: 31
Registered: ‎04-14-1997
Message 3 of 8 (74 Views)

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
Randy Jones_3
Posts: 84
Registered: ‎03-24-2003
Message 4 of 8 (74 Views)

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
ECUse
Posts: 31
Registered: ‎04-14-1997
Message 5 of 8 (74 Views)

Re: Script issue moving from HPUX to Linux for mail

Thanks I believe that would would. I will give it a try.
Acclaimed Contributor
Dennis Handly
Posts: 25,288
Registered: ‎03-06-2006
Message 6 of 8 (74 Views)

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
Advisor
ECUse
Posts: 31
Registered: ‎04-14-1997
Message 7 of 8 (74 Views)

Re: Script issue moving from HPUX to Linux for mail

That works perfectly Dennis. Dang, I never looked at that thread until now.
Advisor
ECUse
Posts: 31
Registered: ‎04-14-1997
Message 8 of 8 (74 Views)

Re: Script issue moving from HPUX to Linux for mail

Dennis provided the information I was looking for.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.