LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2009, 07:21 AM   #1
tucs_123
LQ Newbie
 
Registered: Dec 2008
Posts: 23

Rep: Reputation: 15
Problem in printing HTML content as plain text


Hello friends,

My code perl code is as below.I want to print the contents of file "/dir/Myfile".But problem is that the file "Myfile" contains html content as below.

<TP_INFO> <Mail> </Mail> </TP_INFO>

So the IE treats it as HTML content and doesnt print the content present in the tags.Can any one help me to print HTML content as plain text?


sub PrintLog
{

print "Content-Type: text/plain \n\n";
print "<HTML><HEAD><TITLE></TITLE></HEAD><BODY>\n";
open(PS,"cat /dir/Myfile |") || die "Failed: $!\n";
while ( <PS> )
{

print "$_\n";
print "<BR>\n";

}
print "</BODY></HTML>\n";
}
 
Old 09-16-2009, 09:32 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Try placing the embedded HTML in <PRE></PRE> tags.
--- rod.
 
Old 09-18-2009, 10:15 AM   #3
tucs_123
LQ Newbie
 
Registered: Dec 2008
Posts: 23

Original Poster
Rep: Reputation: 15
Thanks for the reply Rod!! But I dont want to change the content of my file.I just want to print that file showing HTML content in it.Any idea?

like

abdc
<html>hello</html> -->this text should be displayed as it is.
defdg

Last edited by tucs_123; 09-18-2009 at 10:18 AM.
 
Old 09-18-2009, 07:12 PM   #4
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by tucs_123 View Post
Thanks for the reply Rod!! But I dont want to change the content of my file.I just want to print that file showing HTML content in it.Any idea?

like

abdc
<html>hello</html> -->this text should be displayed as it is.
defdg
Write a filter that replaces every '<' with &lt; and every '>' with &gt;, then send it along to the browser. This is how I deal with this in my free HTML editor Arachnophilia
.
 
Old 09-19-2009, 01:07 AM   #5
Dan04
Member
 
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu
Posts: 207

Rep: Reputation: 37
You also need to replace "&" with "&amp;".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
plain text to html convertor app for Linux?? linus72 Linux - Newbie 4 04-07-2009 01:25 PM
Printing plain text from DOS program produces nothing tkalfaoglu Linux - Hardware 0 02-21-2007 11:07 PM
LXer: CLI Magic: Making HTML, manpages from plain text with AsciiDoc LXer Syndicated Linux News 0 12-04-2006 05:21 AM
Plain Text Printing Messed Up milkycow Linux - Newbie 0 10-11-2004 02:27 AM
Printing from lpr to plain text DoubleLetter Linux - General 2 07-19-2002 11:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration