Sponsored Content
Top Forums Shell Programming and Scripting ESC[70G[ and ^M characters in text file Post 302700429 by bunti on Thursday 13th of September 2012 11:22:17 AM
Old 09-13-2012
ESC[70G[ and ^M characters in text file

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 ‘[Smilieunct:]’
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:
Mod Comment Please view this code tag video for how to use code tags when posting code and data.

Last edited by vbe; 09-13-2012 at 12:27 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read text from a file between two characters..

I have a requirement where i have to read from a .sh file a text lying bet characters like 'SELECT' & ';'...Please help me out in this. I am new to shell scripting. (2 Replies)
Discussion started by: goutam_igate
2 Replies

2. Shell Programming and Scripting

Remove special characters from text file

Hi All, i am trying to remove all special charecters().,/\~!@#%^$*&^_- and others from a tab delimited file. I am using the following code. while read LINE do echo $LINE | tr -d '=;:`"<>,./?!@#$%^&(){}'|tr -d "-"|tr -d "'" | tr -d "_" done < trial.txt > output.txt Problem ... (10 Replies)
Discussion started by: kkb
10 Replies

3. UNIX for Dummies Questions & Answers

Help with deleting characters from text file

I have a text file that looks like this: I want to delete the last character of first column in all rows so that my output looks like this: Thanks a lot! (1 Reply)
Discussion started by: evelibertine
1 Replies

4. UNIX for Dummies Questions & Answers

Any way to get rid of ^M characters in a text file using pr?

When I use vi to see what's in the file I get this: int add1(int x) {^M return x + 1;^M} ^Mint subtract1(int x) {^M return x - 1;^M} ^Mint double_it(int x) {^M return x * 2;^M} ^Mint halve_it(int x) {^Mreturn x / 2;^M} ^Mint main() {^M int myint;^M int result;^M ... (2 Replies)
Discussion started by: Nonito84
2 Replies

5. Shell Programming and Scripting

Counting 2 characters with into 2 categories from a text file

I have a tab delimited file of the following format 2 L a 2 G b 2 L c 2 G a 3 G a 3 G b 3 L c 4 L a 4 G a 4 G b 4 L c 4 G a .. ... I want to count the number of G's and L's with in the first column and the third column/categories such that I would get an output file: (6 Replies)
Discussion started by: Lucky Ali
6 Replies

6. Shell Programming and Scripting

Check if the text file has more than 2 characters

Guys, I know that the below command will cut the 13th field from test.txt file awk -F"|" '{print $13}' test.txt The answer would be, CA CN Ohio If we see the 3 rd one, it has more than 2 characters. So i wanted to check this in if condition and i want to get the output if the 13th... (4 Replies)
Discussion started by: AraR87
4 Replies

7. UNIX for Dummies Questions & Answers

^H characters appear when opening text file using vi - RHEL

Version Info: $ cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.8 (Tikanga) $ $ uname -a Linux stryker138 2.6.18-308.13.1.el5 #1 SMP Thu Jul 26 05:45:09 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux I redirected manpage of ksh command's output to a text file as shown... (6 Replies)
Discussion started by: kraljic
6 Replies

8. Shell Programming and Scripting

Remove all junk characters from a text file

I am using flatfile, in that flat file we are getting the junk chars 1)I21001f<82>^Me<85>!h49 Service Charge 2) I21001f‚ e...!h49 Service Charge please tell me how to remove all junk chars in unix scripts. (1 Reply)
Discussion started by: Talari
1 Replies

9. UNIX for Dummies Questions & Answers

How to enter special characters in a text file using vi?

Hi, I need to create a test text file with the special characters \342\200\223 in it and to be able to use sed maybe to delete them I tried doing it using vi by pressing CTRL-V and then typing 342 but it does not work. After pressing CTRL-V and typing 342 it seems to just insert the numbers... (1 Reply)
Discussion started by: newbie_01
1 Replies

10. UNIX for Beginners Questions & Answers

File name starts with esc character.

How can I refer to a file named esc[G ? I need to delete it or move it. TIA (5 Replies)
Discussion started by: wbport
5 Replies
All times are GMT -4. The time now is 03:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy