Hi,
I have a text file which when I do a 'cat' on it looks like below with the OK’s showing in green and any FAIL showing in red.
cat filename output:
===== MySQL Query Check =====
DB mpuser is alive. 733 = Expected 733 Tables. [
OK ]
DB mpuser_wf is alive. 61 = Expected 61 Tables. [
OK ]
===== MySQL Uptime Check =====
UpTime is 33024426 [
OK ]
===== Ensure all interfaces and DB connections are OK =====
=====> Determining DBM-01 & DBM-02 state ...
The states of DBM-01 and DBM-02 are match [
OK ]
DBM-01 DBMHB Online [
OK ]
DBM-01 DBMHB Linking [
FAIL ]
I want to get this output emailed using something like below:
“cat ${TMP_MAIL_OUTPUT} | mail -s "${EMAIL_SUBJECT}" ${EMAIL_RECIPIENTS}”
Also when I try to do a less on the file, it says it "may be a binary file" and when I go in see the following
ESC and ^M characters. These ESC and ^M characters are also coming into the email output when I just want the email to contain the same output as shown on the cat output
[test@test01 jk]$
less mp_16_menu_runner.sh.20120912.regular.sh.email.30858.out
"mp_16_menu_runner.sh.20120912.regular.sh.email.30858.out" may be a binary file. See it anyway?
[HESC[2J===== MySQL Query Check =====
ESC[70G[ ESC[1;32mOKESC[0;39m ]^MDB mpuser is alive. 733 = Expected 733 Tables.
ESC[70G[ ESC[1;32mOKESC[0;39m ]^MDB mpuser_wf is alive. 61 = Expected 61 Tables.
===== MySQL Uptime Check =====
ESC[70G[ ESC[1;32mOKESC[0;39m ]^MUpTime is 33024426
..
..
..
===== Ensure all interfaces and DB connections are OK =====
=====> Determining ABM-01 & QBM-02 state ...
ESC[70G[ ESC[1;32mOKESC[0;39m ]^MThe states of ABM-01 and QBM-02 are match
I’ve tried things like piping file through below and outputting to tmp file and checking if the ESC[70G[ and ^M go away but with no luck at all
dos2unix
tr –d ^M
tr –d ‘[
unct:]’
strings
iconv -f unicode -t ascii mp_16_menu_runner.sh.20120912.regular.sh.email.30858.out
sed 's/\033/,/g' mp_16_menu_runner.sh.20120912.regular.sh.email.30858.out
See below which confirms this is a text file
[test@test01 jk]$
file mp_16_menu_runner.sh.20120912.regular.sh.email.30858.out
mp_16_menu_runner.sh.20120912.regular.sh.email.30858.out: ASCII English text, with CR, LF line terminators, with escape sequences
Any help on how to remove these ESC and ^M characters much appreciated
Many Thanks
Moderator's Comments:
|
|
Please view this code tag video for how to use code tags when posting code and data.
|
|