TIP: Click on subject to list as thread! ANSI
echo: bbs_carnival
to: Phil Kimble
from: Sean Dennis
date: 2018-05-07 18:33:22
subject: A new project

Hello Phil,

07 May 18 12:42 at you wrote to me:

 PK> sed is the one tool/utility that has dodged me for years. Never a
 PK> first time go with it.  If you can wrestle it & come out on the good
 PK> side, you are doing much better than I.

Nothing that Google couldn't help me solve.  What was the trick is using the 
"-i" or "--in-place" switch with sed.

So here's the bash script that does the dirty work.  The expect script is 
called and then sed does some of the work here.

For some reason, I screwed up and in the expect script, I cut off the last few 
lines of the output and that's something I will fix soon and release a fix.

=== Cut ===
#!/bin/bash
cd /opt/mbse/bin
## It's a "noisy" script so send any output to /dev/null
expect weather.expect > /dev/null 2>&1
## Trim off the first and last lines
sed -i '1d;$d' weather.txt
## Add a blank line to the top
sed -i '1i \\n' weather.txt
## Add a blank line at the bottom
sed -i '$a \\n' weather.txt
## Dump the extra prompt in the text file
sed -i '/   Press Return to continue, M to return to menu, X to exit: /d' 
weather.txt
## Get rid of the control codes (^M)
cat weather.txt | col -b > weather.asc
## Put the textfile in my BBS' textfiles directory
rm --force /opt/mbse/share/int/txtfiles/en/weather.asc
mv weather.asc /opt/mbse/share/int/txtfiles/en/weather.asc
rm weather*.txt
=== Cut ===

Here's the expect script:

=== Cut ===
spawn telnet rainmaker.wunderground.com
expect "Press Return to continue:"
send "\r"
expect "or enter 3 letter forecast city code-- "
send "TRI\r"
log_file "weather.txt"
expect "Press Return to continue, M to return to menu, X to exit: "
send "\r"
log_file
expect "Selection:"
send "x\r"
expect eof
=== Cut ===

Later,
Sean

... Nothing is free.  Even age.  Age is the fee God charges for life.
--- GoldED+/LNX 1.1.5-b20170303
* Origin: Outpost BBS * Limestone, TN, USA (1:18/200)
SEEN-BY: 15/0 18/200 19/36 34/999 90/1 116/18 120/302 331 123/140 128/2
SEEN-BY: 153/7715 218/700 220/60 222/2 230/150 152 240/1120 250/1 261/38 100
SEEN-BY: 266/404 512 267/155 275/100 280/1027 282/1031 1056 291/1 111 320/119
SEEN-BY: 320/219 340/400 342/13 393/68 396/45 633/267 280 640/384 712/620 848
SEEN-BY: 770/1 801/161 189 2320/100 105 3634/12 5020/1042
@PATH: 18/200 261/38 712/848 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.