- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Telnet email: how to include a file content in an ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2017 12:12 AM
11-22-2017 12:12 AM
Telnet email: how to include a file content in an email
Hi,
I wrote a HP-UX script. It used telnet to send email.
Although it works, I couldn't include a text file's content in the email I sent.
I have tried and AIX example but it didn't work.
Can you help me?
AIX telnet example:
EMAILSENDER="xxx@1234.com
EMAILRECEIVER1="yyy@1234.com"
EMAILRECEIVER2="zzz@1234.com"
REPORTCONTENT=`cat /u02/db_script/outlog/mon_block.log`
telnet relay.1234.com 25 << EOF
helo
mail from:$EMAILSENDER
rcpt to:$EMAILRECEIVER1
rcpt to:$EMAILRECEIVER2
data
From: $EMAILSENDER
To: $EMAILRECEIVER1
To: $EMAILRECEIVER2
Subject: POS Oracle Blocking session exists
$REPORTCONTENT
.
quit
EOF
However, unluckily, I couldn't use the "$REPORTCONTENT" method to display a text file's content in an email by telnet.
Can you help me?
Thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2017 02:25 AM - edited 11-22-2017 02:48 PM
11-22-2017 02:25 AM - edited 11-22-2017 02:48 PM
Re: Telnet email: how to include a file content in an email
> Although it works, I couldn't include a text file's content in the email I sent.
What do you get instead?
Why not just use mailx?
If you replace "telnet relay.1234.com 25" by "cat" you should see what telnet is getting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2017 10:51 AM
11-22-2017 10:51 AM
Re: Telnet email: how to include a file content in an email
> I have tried and AIX example but it didn't work.
Where did you find your "AIX example"?
> $REPORTCONTENT
I don't see how this could possibly work. Is the AIX Telnet client
scanning what I type, looking for $<var_name>, and then sending file
contents instead of what I typed? I doubt it.
> What do you get instead?
I know nothing, but I'd bet a small sum on "$REPORTCONTENT".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2017 12:04 PM
11-22-2017 12:04 PM
Re: Telnet email: how to include a file content in an email
> I don't see how this could possibly work.
Why not? This is a here doc and the value of the variable should be substituted.
Though I would use this instead: $( < /u02/db_script/outlog/mon_block.log)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2017 02:18 PM
11-22-2017 02:18 PM
Re: Telnet email: how to include a file content in an email
> Why not? This is a here doc [...]
Thanks for reading it to me. I must have been even less alert than
usual when I read it for myself. Sigh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2017 01:02 AM
11-23-2017 01:02 AM
Re: Telnet email: how to include a file content in an email
Hi all,
mailx doesn't wrok in my DEV and UAT but only production, so, in order to standardize the source code, I use telnet.
I just simplily to want: write a script and put it into crontab, it will grep our SAP Oracle alert log regularly, eg. per hour, then, once there is an ORA message in the alert log, it will send emails to our team.
The email will include all the ORA lines from the alert log. But I couldn't make it out.
My script:
> cat greporaalert.sh
#!/bin/sh
EMAILSENDER="it_dba@1234.com"
EMAILRECEIVER1="it_dba@1234.com"
EMAILRECEIVER2="it_manager@1234.com"
REPORTCONTENT='cat /.../ORAmesg.log'
grep "ORA-" /.../alert_DEV.log > /oracle/DEV/ORAmesg.log
count=$(cat /.../ORAmesg.log | wc -l)
if [ "$count" != 0 ]
then
telnet relay.1234.com 25 << EOF
helo
mail from: $EMAILSENDER
rcpt to: $EMAILRECEIVER1
rcpt to: $EMAILRECEIVER2
data
From: $EMAILSENDER
To: $EMAILRECEIVER1
To: $EMAILRECEIVER2
Subject: [Alert] ORA message is found
ORA message is found.
Please read the alert log for details:
/..../alert_DEV.log
$REPORTCONTENT
.
quit
EOF
fi
It only displays:
ORA message is found.
Please read the alert log for details:
/..../alert_DEV.log
cat /.../ORAmesg.log
It just displayed the command: cat /.../ORAmesg.log but not the content of the ORAmesg.log file.
Any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2017 11:11 AM
11-23-2017 11:11 AM
Re: Telnet email: how to include a file content in an email
Try this to display the ORAmesg.log directly rather than using REPORTLOG variable:
$(<$ORAmesg.log)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2017 11:34 AM
11-23-2017 11:34 AM
Re: Telnet email: how to include a file content in an email
> It only displays:
> [...]
> cat /.../ORAmesg.log
That's a clue.
> REPORTCONTENT='cat /.../ORAmesg.log'
echo $REPORTCONTENT
You seem to be using apostrophes (') where you want back-ticks/grave
accents (`). Or, you might want both, depending on how much stuff you
want to store in that shell variable.
> $(<$ORAmesg.log)
One advantage of the "$()" notation is that it's visually clearer
(and less font-dependent) than "``" (v. "''").
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2017 01:07 PM
11-23-2017 01:07 PM
Re: Telnet email: how to include a file content in an email
> One advantage of the "$()" notation is that it's visually clearer
And most important of all, you can nest them.
@molo1: mailx doesn't work in my DEV and UAT but only production
Why not? You don't have sendmail working?
> REPORTCONTENT='cat /.../ORAmesg.log'
This is NOT what you had in the first post. You had `` and not ''.
> count=$(cat /.../ORAmesg.log | wc -l)
Remove the evil cat:
count=$(wc -l < ./.../ORAmesg.log)
But better yet, remove the wc(1) completely:
if [ -s ./.../ORAmesg.log ]; then