Subject: Viewing HTML in pine

From: Issac Roth <[email-masked]>
Date: Tue, 2 Dec 1997 02:56:56 -0800 (PST)

[Another installment of "how do I view html attachments with pine"]

Here is my version of viewing HTML attachments and included HTML from pine.
This is a hack. It is ugly bad code. Use however you want. Other people have
other solutions that work better or worse for them. You may want to try
theirs.

I have this script as a file called ~/bin/view_html.perl

I have a .pinemailcap file which is in my pine mailcap search path.
I have this in my .pinemailcap file:

text/html; ~/bin/view_html.perl %s; needsterminal

That allows me to view attachments. If I get an email which contains HTML
which is not an attachment, I use the "|" command to pipe the message to this
script.

Have fun,

Issac

#!/path/to/perl5 -w

# --------------
# view_html.perl
# takes html in stdin or in a file and raises a currently running netscape
#  to the front with that bit of html in it
# netscape uses X resources to communicate with running instantiations of 
#  itself, so you can run this from a different machine (mail server) than
#  your copy of netscape is running on (workstation)
# very unpolished, use at your own risk
# Weird things can happen if your DISPLAY variable is not set correctly. 
# Beware!
#
# Issac Roth ([email-masked]) 1-Dec-1997
# ----------------------------------------------

# ------ things to change for individual situations

$NETSCAPE = 'netscape4';
$LYNX = '/usr/local/bin/lynx';
  ## TMPDIR should be available via NFS with the same path from all systems
  ## you might run this or a browser from. This dir should already exist.
$TMPDIR = "/users/$ENV{'USER'}/tmp";      # leave off trailing slash

# ------- you probably don't need to change things below here

$htmlfile = "$TMPDIR/htmljunk.$$.html";

# copy the html to a file that is available over NFS
open(TMPHTMLFILE,">$htmlfile") || die "Couldn't open tmp file\n";
while (<>) {
    print TMPHTMLFILE;
}
close(TMPHTMLFILE) || die "couldn't write tmp file\n";

# launch browser
# first try netscape, if we're running X
unless (defined($ENV{'DISPLAY'})) {
    # no X11, run lynx
    system("$LYNX -force_html $htmlfile");
} else {
    
    # we have X11
    # fork to try to tell a currently running netscape to open our html file
    # if we're running from a mailreader, this is good, because it returns
    # control to the mailreader immediately
  FORK: {
      if ($pid = fork) {
	   # parent
	  exit(0);
      } elsif (defined $pid) {
	  # child
	  if (`$NETSCAPE -remote \"openURL(file:$htmlfile)\" 2>&1` =~ /not running on display/) {
	      # launch a new one if one didn't exist already
	      system("$NETSCAPE $htmlfile");
	  }
      }

# ---- the rest of this is all forking error condition nonsense
      elsif ($! =~ /No more process/) {
	# EAGAIN, supposedly recoverable fork error
	# try forking again
	sleep 2;
	redo FORK;
    } else {
	# something strange happened with forking, so die
	die "Can't fork: $! - Try again\n";
    }
  }
}

# clean up after ourselves
unlink($htmlfile);

---

From: Solstice <[email-masked]>
Date: Tue, 2 Dec 1997 10:57:06 -0500 (EST)

> [Another installment of "how do I view html attachments with pine"]

I have something similar but it doesn't require PERL:

1)	copy the /etc/mailcap to your own directory under the file
	name .mailcap

2)	search for the phrase or line "Texts and Fonts"

3)	add the following lines:

	text/html; shownonascii iso-8859-1 %s; copiousoutput
	text/html; shownonascii iso-8859-8 %s; copiousoutput
	text/html; shownonascii iso-8859-7 %s; copiousoutput

4)	Modify your .pinerc file to read:

# Sets the search path for the mailcap cofiguration file.
# NOTE: colon delimited under UNIX, semi-colon delimited under DOS/Windows/OS2.
mailcap-search-path=[home directory paty]/.mailcap:/etc/mailcap

After that... start pine and you should be able to view HTML codes via
PINE.

"IF WE'RE THE ONLY LIFE IN THE UNIVERSE, WOULDN'T IT BE A WASTE OF SPACE."
John "Highway" Tze-Chang Wu           Alpha Phi Omega Nat'l Svc Fraternity
[email-masked]                        http://www.vni.net/apo (Epsilon Mu)
http://www.vni.net/~highway            Central Perk Coffee House (Friends)
(World Wide Web Developer)             http://www.vni.net/~highway/Friends