HTML: Display contents of file using Variable


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers HTML: Display contents of file using Variable
# 1  
Old 10-25-2013
HTML: Display contents of file using Variable

Code:
<tr><td bgcolor=#D7EBAD><b>Instructions :</b></td>
<td>`cat temp.txt`</td></tr>

Hi Experts,

I have an requirement of displaying file contents in HTML mail , for which am using the above approach, Where as the output is kind of not as expected.

If there are 5 lines in the file, in the output mail all are appearing as one after another.
I want the contents to be displayed as it is in the output HTML mail.

Any pointers would be really appreciated.
# 2  
Old 10-25-2013
Please define "not as expected". html does not necessarily format text in "lines" as they exist in a file. You may need to add paragraph breaks, for example.
# 3  
Old 10-25-2013
Thanks for your reply jim mcnamara.

say like the contents of the file is like

cat filename.txt
This is the first line.
This is the second line.
This is the third line.

In the HTML mail its appearing as
This is the first line.This is the second line.This is the third line.

I would need in the HTML mail also it should appear as the contents of the file.
# 4  
Old 10-25-2013
Use a br tag to insert a single line break:
Code:
#!/bin/ksh

{
        while read line
        do
                print "${line}<br>"
        done < filename.txt
} | mailx -s "Subject
Content-Type: text/html" user@domain.com

# 5  
Old 10-25-2013
Hi Yoda,

Thanks for your reply.

that was an nice one. will try that.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

How to create a link that will display the contents of a PHP variable?

Greetings, I've wrote a script that when you point your browser to a machine it displays info about itself. Below is a small snippet of the script: <?php $iloipaddr = `ipmitool lan print | grep 'IP Address ' | cut -d\: -f2 | sed 's/ //'`; $sftwrlist = `rpm -qa | sort`; ?> <p><a... (9 Replies)
Discussion started by: crimso
9 Replies

2. UNIX for Beginners Questions & Answers

Storing file contents to a variable

Hi All, I was trying a shell script. I was unable to store file contents to a variable in the script. I have tried the below but unable to do it. Input = `cat /path/op.diary` Input = $(<op.diary) I am using ksh shell. I want to store the 'op.diary' file contents to the variable 'Input'... (12 Replies)
Discussion started by: am24
12 Replies

3. Shell Programming and Scripting

Extract both contents from a html file and do printing

Hi there, Print IP Address: grep 'HostID :' 10.244.9.124\ nessus.html | awk -F '<br>' '{print $12}' | tr -s ' ' | awk -F ':' '{print "<tr><td>" $2 "</td><td>"}' Print Respective Ports: grep 'classsubsection\|./tcp\|./udp' 10.244.9.124\ nessus.html | grep -v 'h2.classsubsection... (3 Replies)
Discussion started by: alvinoo
3 Replies

4. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

Hi one of the output of the command is as below # sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/' Resource List : <br> *************************** 1. row ***************************<br> ... (2 Replies)
Discussion started by: vivek d r
2 Replies

5. Homework & Coursework Questions

How to read contents of a file into variable :(

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have to read the contents of each field of a file creating user accounts. The file will be of format : ... (6 Replies)
Discussion started by: dude_me5
6 Replies

6. Shell Programming and Scripting

How to read contents of a file into variable :(

My file is in this format : username : student information : default shell : student ID Eg : joeb:Joe Bennett:/bin/csh:1234 jerryd:Jerry Daniels:/bin/csh:2345 deaverm: Deaver Michelle:/bin/bash:4356 joseyg:Josey Guerra:/bin/bash:8767 michaelh:Michael Hall:/bin/ksh:1547 I have to... (1 Reply)
Discussion started by: dude_me5
1 Replies

7. Shell Programming and Scripting

Grep a pattern given in one file at other file and display its corresponding contents as output.

***************************************** Right now i have this current system. I have two files say xxx.txt and yyy.txt. xxx.txt is with list of patterns within double quotes. Eg. "this is the line1" "this is the line2" The yyy.txt with lot of lines. eg: "This is a test message which... (7 Replies)
Discussion started by: abinash
7 Replies

8. Shell Programming and Scripting

Storing the contents of a file in a variable

There is a file named file.txt whose contents are: +-----------------------------------+-----------+ | Variable_name | Value | +-----------------------------------+-----------+ | Aborted_clients | 0 | | Aborted_connects | 25683... (6 Replies)
Discussion started by: proactiveaditya
6 Replies

9. Shell Programming and Scripting

how to display the output file in an html format using perl

Hi, I have written a perl script to dispaly some statements from a file but i want the output statements to be dispalyed in an HTML format.Is it possible for me to do in perl scripting? Please help me with ur thoughts. Thanks In Advance Meva. (1 Reply)
Discussion started by: meva
1 Replies

10. Shell Programming and Scripting

Unable to display correctly the contents of a file without a line feed

I am using AIX and ksh. I need to display the contents of a file that has a pid (process id). Because the file is open, it doesn't have the line feed or new line, so for some reason if I do this: `cat $pid` , where $pid is the name of the fully qualified file, it displays test3.sh: 426110:... (1 Reply)
Discussion started by: Gato
1 Replies
Login or Register to Ask a Question