UNIX/Linux - awk - displaying unxpected ! character when viewed in mail; but not in actual file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX/Linux - awk - displaying unxpected ! character when viewed in mail; but not in actual file
# 1  
Old 04-06-2017
UNIX/Linux - awk - displaying unxpected ! character when viewed in mail; but not in actual file

Greetings Experts,
I am on AIX using ksh; I am processing the input files and generating a awk_output.txt file using AWK. By reading that awk_output.txt file, I am building a output.html file which is cat and then fed to /usr/sbin/sendmail .When the shell script is triggered through command line, the script processes the multiple files at the given location and then builds the awk_output.txt file using awk Then by reading the contents of the awk_output.txt through while loop, I am building the output.html file with respective html tags. Then /usr/sbin/sendmail is invoked to read the contents of output.html file using echo `cat output.html` and send mail. I know without sample script/file it is really difficult to point out the exact issue. But I can't share the script/file as it is on remote machine.

Issue: When the mail is received, I see that there is extra ! {!followed by a space} at random locations at 5th line and 11th line. ( It occurs on the random line numbers after every re-run which deletes the same file and re-creates it )
When I open the same output.html file directly in the Unix server ( which opens in Internet Explorer), I am seeing the data as expected i.e., without ! I am really frustrated with this. Please note that when the number of characters in the output.html file is low (around 200 characters; 12 rows with 3 columns; column1 length=10; column2_len=3; column3_len=3) this issue doesn't exist. But when the output.html file contains more number of characters (12 rows with 5 columns; column1 length = 20; column2_len=30; column3_len=3; column4_len=3; column5_len=5) the issue creeps up. Assumption of any embedded non-printable character in the script is overruled as we pass 3 different arguments to the script 3 times and the ! occurs at different locations.
Eg contents when opened the output.html file in Unix server which doesnot have issue i.e., without ! :
Code:
account_info_file1|account_number,business_date1|yes|yes
account_info_file2|account_number,business_date2|yes|no
....
account_info_file5|account_number,business_date5|yes|yes
...
account_info_file12|account_number,business_date12|no|no

Eg contents seen through outlook mail which has issue i.e., ! occurs at random locations
Code:
account_info_file1|account_number,business_date1|yes|yes
account_info_file2|account_number,business_date2|yes|no
....
account_info_file5|account_nu! mber,business_date5|yes|yes
...
account_info_file12|account_number,busines! s_date12|no|no

As you can see, when the actual output.html file is opened in Unix server, it opens in Internet Explorer and I don't see any ! symbols. But the same file is cat and sent through mail and then I see those ! symbols at random positions at about 3 times. I have verified the octaldump of the lines that had ! in between them in the output.html file and I don't see any issues with it. Can you please help to understand and resolve this. Thank you for your time.
# 2  
Old 04-06-2017
Why are you using
Code:
echo `cat output.html`

rather than
Code:
cat output.html

The first leaves all kinds of characters open to interpretation by the shell ..

How does that work with sendmail? What do you do exactly?
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 04-07-2017
Excellent Scrutinizer. You saved me Smilie There was already an existing script written by someone. So, re-used it by modifying the needed ones. Your suggestion worked perfectly. Again, thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to get output in mail in actual format?

I need top load memory and cpu uses in mail. I am getting mail, but output is coming in sentence format. can help me, how can I get in actual format. below is the command. echo `ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head`|mailx -r `hostname -s`@abc.com abc@abc.com (5 Replies)
Discussion started by: yash_message
5 Replies

2. UNIX for Advanced & Expert Users

Can I prevent a script from being viewed?

i've vi'ed some scripts in the past and when i did, my screen froze. i had to go to another terminal and kill the vi process before i was able to get back my screen. how can i replicate this behavior on purpose? i want be able to do this also if the file or script was doubled clicked, say... (17 Replies)
Discussion started by: SkySmart
17 Replies

3. Programming

How to send a file in e-mail from on Linux C++?

Hi ! I-m copile from source a C++ program from tutorials from internet. I don't understendig any programing languages.. but compiled aplication running ok. I-ts possible to add in my used program, lines to send one file from config directory in e-mail, to my e-mail adress ? I want to run... (2 Replies)
Discussion started by: kraftwerk
2 Replies

4. Shell Programming and Scripting

Mail utility not displaying escape sequences

Hello! I created a file that displays text underlined. However when I pass the file into the mail utility it doesnt display the underline. Here is the code: echo "\n\033 cat test_underline.txt mail -s "testing of underline" <email_address> < test_underline.txt Any ideas?... (8 Replies)
Discussion started by: DPERTS
8 Replies

5. Shell Programming and Scripting

Use mutt or mail in different contexts - Linux or Unix

Hi All, I need to write a "portable" shell script that can send mail from Unix or Linux servers. In my server Linux I find mutt and I need to attach a file In my server Unix mutt is not present. Only mail/mailx. In this case for attaching a file I need to pipe the uuecode command. My... (1 Reply)
Discussion started by: gio123bgg
1 Replies

6. UNIX for Dummies Questions & Answers

Unix and Linux...what to look for in mail.log?

Hi all. I have a couple of scripts looking at my syslog.log, mail.log, and messages logs. My scripts work well with syslog.log and messages logs. I use grep function and then make exceptions to things that I know happen often and that way can investigate better without being buried with... (2 Replies)
Discussion started by: zixzix01
2 Replies

7. UNIX for Dummies Questions & Answers

Removing ^@ character at the end own belowof Linux file

Hi, I have a Linux file which has content as sh (0 Replies)
Discussion started by: bhuvanas
0 Replies

8. Shell Programming and Scripting

How to attach a file in Linux mail command

How to attach a file in Linux mail command Hi Guys, Is there any way to attach a file in Linux mail command without using "uuencode"? i.e. Code: file=/a/b/c/d/file.txtmail -s "Giga aks" abc@123.com <<HDoc`uuencode $file $file 2>/dev/null`HDoc Here, I don;t want to use 'uuencode'... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

9. OS X (Apple)

Use UNIX to track web sites viewed?

I'm on OSX 10.4. I was wondering if you can use UNIX terminal to track what web sites have been viewed on this Mac... Thank you! (1 Reply)
Discussion started by: tracymanusa
1 Replies
Login or Register to Ask a Question