HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script output to email arrives unreadable
Operating System - HP-UX
1830340
Members
2329
Online
110001
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-18-2008 04:20 AM
11-18-2008 04:20 AM
Script in cron checks FileSystems and if over a certain threshold it sends an email alert. The output arrives mainly as gibberish like this:
?&f1k16d-1L ?&f2k16d-1L ?&f3k16d-1L
?&f4k16d-1L ?&f5k16d-1L ?&f6k16d-1L
?&f7k16d-1L ?&f8k7d1L Cancel??&s1A?&jB?&jR?&f1k16d-1L
?&f2k16d-1L ?&f3k16d-1L ?&f4k16d-1L
?&f5k16d-1L ?&f6k16d-1L ?&f7k16d-1L
?&f8k7d1L Cancel??&s1A?&jB?&jR?&f1k14d1L Display Msg
?&f2k14d1L Mail Msgm?&f3k15d1L Reply to Msgr?&f4k14d1L Save
Msgs?&f5k14d1L Delete Msgd?&f6k14d1LUndelete Msgu?&f7k14d1L Print
Msgp?&f8k14d1L Quit
ELMq?&s1A?&jB?&jR?&s1A?&jB?&jR?&s0A?&j@?&f1k16d-1L
?&f2k16d-1L ?&f3k16d-1L ?&f4k16d-1L
?&f5k16d-1L ?&f6k16d-1L ?&f7k16d-1L
?&f8k7d1L Cancel??&s1A?&jB?&jR?&f1k16d-1L ?&f2k16d-1L
?&f3k16d-1L ?&f4k16d-1L ?&f5k16d-1L
?&f6k16d-1L ?&f7k16d-1L ?&f8k7d1L
Cancel??&s1A?&jB?&jR?&f1k14d1L Display Msg
?&f2k14d1L Mail Msgm?&f3k15d1L Reply to Msgr?&f4k14d1L Save
Msgs?&f5k14d1L Delete Msgd?&f6k14d1LUndelete Msgu?&f7k14d1L Print
Msgp?&f8k14d1L Quit ELMq?&s1A?&jB?&jR?&s1A?&jB?&jR?&s0A?&j@
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
sh /scripts/disk_chk.sh 2>&1 >/dev/null
SCRIPT:
#!/bin/sh
for a in `bdf -l | grep -v "Mounted" | grep -v "used" | grep -v "deviceFile"| sed -e "s/%//" | awk '{print $6, $5, $4}' | awk
'{print $1}'`
do
fs=`echo $a | awk '{print $1}'`
for b in `bdf -l | grep -v "Mounted" | grep -v "used" | grep -v "deviceFile" | sed -e "s/%//" | awk '{print $6, $5, $4}' | gre
p "$a " |awk '{print $2}'`
do
fsval=`echo $b`
done
warn=95
crit=95
if [ $fsval -gt $warn ]
then elm -s "WARNING: $fs is at $fsval" email@xyz.com fi
if [ $fsval -gt $crit ]
then elm -s "CRITICAL: $fs is at $fsval" email@xyz.com fi
done
On other systems it is not arriving in this format. Any ideas?
HP-UX 11.31
?&f1k16d-1L ?&f2k16d-1L ?&f3k16d-1L
?&f4k16d-1L ?&f5k16d-1L ?&f6k16d-1L
?&f7k16d-1L ?&f8k7d1L Cancel??&s1A?&jB?&jR?&f1k16d-1L
?&f2k16d-1L ?&f3k16d-1L ?&f4k16d-1L
?&f5k16d-1L ?&f6k16d-1L ?&f7k16d-1L
?&f8k7d1L Cancel??&s1A?&jB?&jR?&f1k14d1L Display Msg
?&f2k14d1L Mail Msgm?&f3k15d1L Reply to Msgr?&f4k14d1L Save
Msgs?&f5k14d1L Delete Msgd?&f6k14d1LUndelete Msgu?&f7k14d1L Print
Msgp?&f8k14d1L Quit
ELMq?&s1A?&jB?&jR?&s1A?&jB?&jR?&s0A?&j@?&f1k16d-1L
?&f2k16d-1L ?&f3k16d-1L ?&f4k16d-1L
?&f5k16d-1L ?&f6k16d-1L ?&f7k16d-1L
?&f8k7d1L Cancel??&s1A?&jB?&jR?&f1k16d-1L ?&f2k16d-1L
?&f3k16d-1L ?&f4k16d-1L ?&f5k16d-1L
?&f6k16d-1L ?&f7k16d-1L ?&f8k7d1L
Cancel??&s1A?&jB?&jR?&f1k14d1L Display Msg
?&f2k14d1L Mail Msgm?&f3k15d1L Reply to Msgr?&f4k14d1L Save
Msgs?&f5k14d1L Delete Msgd?&f6k14d1LUndelete Msgu?&f7k14d1L Print
Msgp?&f8k14d1L Quit ELMq?&s1A?&jB?&jR?&s1A?&jB?&jR?&s0A?&j@
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
sh /scripts/disk_chk.sh 2>&1 >/dev/null
SCRIPT:
#!/bin/sh
for a in `bdf -l | grep -v "Mounted" | grep -v "used" | grep -v "deviceFile"| sed -e "s/%//" | awk '{print $6, $5, $4}' | awk
'{print $1}'`
do
fs=`echo $a | awk '{print $1}'`
for b in `bdf -l | grep -v "Mounted" | grep -v "used" | grep -v "deviceFile" | sed -e "s/%//" | awk '{print $6, $5, $4}' | gre
p "$a " |awk '{print $2}'`
do
fsval=`echo $b`
done
warn=95
crit=95
if [ $fsval -gt $warn ]
then elm -s "WARNING: $fs is at $fsval" email@xyz.com fi
if [ $fsval -gt $crit ]
then elm -s "CRITICAL: $fs is at $fsval" email@xyz.com fi
done
On other systems it is not arriving in this format. Any ideas?
HP-UX 11.31
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2008 04:27 AM
11-18-2008 04:27 AM
Re: script output to email arrives unreadable
>email arrives unreadable
These are fancy escape sequences for drawing the screen.
You should NOT be using elm to mail in a script. Simply use mailx:
mailx -s "CRITICAL: $fs is at $fsval" email@xyz.com < /dev/null
These are fancy escape sequences for drawing the screen.
You should NOT be using elm to mail in a script. Simply use mailx:
mailx -s "CRITICAL: $fs is at $fsval" email@xyz.com < /dev/null
- Tags:
- mailx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2008 05:21 AM
11-18-2008 05:21 AM
Solution
Hi Briano:
You could greatly reduce the number of processes this script uses as well as its complexity. Consider something like this (where 'awk' skips the first header line and eliminates the "%" character:
# cat bdfalert
#/usr/bin/sh
typeset WARN=50
typeset CRIT=75
bdf -l | awk '{if (NR>1) {sub("%","",$5);print $6,$5}}' | \
while read FS PCT X
do
if [ "${PCT}" -gt "${CRIT}" ]; then
mailx -s "CRITICAL: ${FS} is at ${PCT}" email@xyz.com < /dev/null
elif [ "${PCT}" -gt "${WARN}" ]; then
mailx "WARNING : ${FS} is at ${PCT}" email@xyz.com < dev/null
fi
done
exit 0
...Note that I let the shell's 'read' pluck out the variables from each line filtered by 'awk' thus presenting them to the shell logic. It is always good practice to enclose interpolated variables in curly braces and add double quotes around them in tests.
I reordered your 'if' statements so that you don't get both a "warning" and a "critical" message when a critical leval has been reached.
Regards!
...JRF...
You could greatly reduce the number of processes this script uses as well as its complexity. Consider something like this (where 'awk' skips the first header line and eliminates the "%" character:
# cat bdfalert
#/usr/bin/sh
typeset WARN=50
typeset CRIT=75
bdf -l | awk '{if (NR>1) {sub("%","",$5);print $6,$5}}' | \
while read FS PCT X
do
if [ "${PCT}" -gt "${CRIT}" ]; then
mailx -s "CRITICAL: ${FS} is at ${PCT}" email@xyz.com < /dev/null
elif [ "${PCT}" -gt "${WARN}" ]; then
mailx "WARNING : ${FS} is at ${PCT}" email@xyz.com < dev/null
fi
done
exit 0
...Note that I let the shell's 'read' pluck out the variables from each line filtered by 'awk' thus presenting them to the shell logic. It is always good practice to enclose interpolated variables in curly braces and add double quotes around them in tests.
I reordered your 'if' statements so that you don't get both a "warning" and a "critical" message when a critical leval has been reached.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2008 05:28 AM
11-18-2008 05:28 AM
Re: script output to email arrives unreadable
Shalom,
Try this email attachment sender script in conjunction with JRF's recommended changes.
http://www.hpux.ws/?p=7
SEP
Try this email attachment sender script in conjunction with JRF's recommended changes.
http://www.hpux.ws/?p=7
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Tags:
- attachments
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP