[GreenKeys] Heavy Metal

Henry Minsky [email protected]
Thu, 03 Jan 2002 23:39:11 -0500


I have the AP newswire headlines printed out each morning for me on the TTY
at 7:30 AM, it's my alarm clock :-)

Actually, I have the machine print a little daily paper, which has the 
weather forcecast (from
"http://www.mit.edu/weather?bos") and the news headlines, as well as the
subject lines from any email I got during the night. Then I get woken up when
it prints and can read it while eating breakfast.

What I do is the following (I am using a Linux server to drive the teletype)

I am running AOLserver as my web server. It has a built in Tcl scripting
language.

The Tcl script below fetches an XML feed of the news headlines, and
runs some regular expressions to turn them into plain text. I suggest
you look at the web server www.newsisfree.com, it has XML format
and HTML format newsfeeds of hundreds of news services and newspapers.

You could do the same thing without using Tcl embedded in the we bserver,
by writing a script in your favorite scripting langauge that grabs the
web page raw content using "wget" or "lynx -source", then cleans it up
with a few regexps.

I actually have a "client-server" system running for the teletype: I have a 
dedicated
laptop with a wireless card which talks to the TTY and also runs a TCP 
daemon. Then
my main server for the house runs a cron job every morning which grabs the
news and then connects to the TTY machine and prints out the data.

There is actually a standard Internet protocol for gatewaying between 
serials ports
and TCP ports. A free software implementation is called 
msredird-0.2.tgz         or "sredird"
and is described as "serial port redirector that is compliant with the RFC 
2217 "Telnet Com Port Control Option" protocol"

Devices such as the Axis network Serial Server
http://www.axis.com/products/cam_2490/index.htm  use this protocol.

Tcl code here:

set hdr [ns_set create]
ns_set put $hdr "Connection" "close"
ns_set put $hdr "Host" "www.newsisfree.com"

set raw [util_httpget "http://www.newsisfree.com/HPE/xml/feeds/69/1469.xml"]

#       <title>India Mulling Response to Attack</title>
#       <link>http://www.newsisfree.com/click/-3,960681/</link>
#       <description>India's prime minister said Wednesday that the 
government is discussing war, as well as diplomacy, as a response to last 
week's suicide attack on Parliament that it blames on Pakistan-based 
militants.</description></item>
#<item>

set isbody 0
set content ""

foreach line [split $raw "\n"] {
     if {[string match "*<item>*" $line]} {
         set isbody 1
     }
     if {$isbody == 1} {
         if {[regexp "<title>(.*)</title>" $line ignore headline]} {
             append content "$headline\n"
         }
         if {[regexp "<description>(.*)</description>" $line ignore desc]} {
             append content "[wrap_string $desc 73]\n\n"
         }
     }
}

#regsub -all "\n" $rawtext "\n" page

set date [gets [open "|/bin/date" r]]

set msg "AP World News $date\n$content"
regsub -all "\n" $msg "\r\n" msg

ns_return 200 text/plain $msg


At 09:27 PM 1/3/02 -0700, you wrote:
> >... but it would be fairly
> >easy to add a feature to have Heavy Metal watch a magic folder or directory
> >and automatically print out (and then delete) any text file you drop into
> >it.
>
>Bill:
>
>Hmm.  Watch a magic folder.  That sounds handy.  A program could simply
>print to a file in that directory (in text format), HM could grab it, print
>it, then delete it.  Quite cool.  And TTY auto-motor control can be handled
>by HM.
>
>I'm still looking for a way to get the CNN breaking news emails to
>automatically print on the tty (by the time the find bin-livin-too-long).
>I need to automatically get the text out of an email program to a text
>file, and also strip down some of the extra crap and format it into a short
>tty-friendly news message.  If this message file is then saved to the HM
>magic folder, the printing would be automatic!   It would be quite cool to
>have the tty just fire up and print news in semi-realtime.  Anyone have
>ideas on sending an email message automatically to a file?  My old eudora
>filters don't have that option, but perhaps another program does.  How
>about piping it through a simple text filter?  Even something as simple as
>delete N lines, save M lines...
>
>gil
>
>;-----------------------------------------------------------
>;  vaux electronics, inc.             480-354-5556
>;  http://www.vauxelectronics.com     (fax: 480-354-5558)
>;-----------------------------------------------------------
>_______________________________________________
>GreenKeys mailing list
>[email protected]
>http://mailman.qth.net/mailman/listinfo/greenkeys