Custom Search

Tuesday, November 17, 2009

Interfacing the Medical Transcription
Foot Pedal With Mplayer

Those of you who are hearing mplayer for the first
time should certainly see this article.

It is the best multimedia application out there and
it is written in pure C. It is amazing stuff. A grand
old project with an amazing cornucopia of features.

Those of you who have not heard of the footpedal
do not need to worry. It is a footrest with three
buttons which you can press with the toe.
Here is a picture.

It connects via the 9 pin serial connector to the
serial port of the computer. Before we get to the
technical details we do need to know something
about the medical transcription industry.

Every technical problem needs a business goal to
meet. Sometimes it is not very obvious as in the
case of academic UNIX tools, but without having
an appreciation of the real purpose of the project,
one cannot do well in business. Technical solutions
do not exist in isolation.

Medical transcription is the process of converting
a doctor's voice recordings into English text. The
doctor would have spoken at varying speeds and
with different accents. A medical transcriptionist
has the job of translating his spoken words into
the written word.

I am sure you can imagine that this is no easy task.
The transcriptionist has to listen to the dictation
multiple times at various speeds to figure out what
on earth the doctor is trying to say.

His/her fingers are typing the message in the audio,
and you wish to be able to rewind, pause/play and
fast forward the recording with the foot. That is
where a footpedal comes in. You can't use the mouse
or keyboard for this since the hands are busy typing
out text.

While the hand is typing the foot will be interacting
with the audio player to help the transcriptionist to
accurately translate the dictation into English text.

The footpedal is a passive device with no power and
no moving parts. There are 3 switches as you can see
above. The left pedal is connected to the DSR pin(8),
the middle pedal is connected to the CTS pin(6), and
the right pedal is connected to the DCD pin(1).

I figured this out using a perl script given here.


use Device::Modem;

  my $modem = new Device::Modem( port => '/dev/tty00' );

        /*
         if( $modem->connect( baudrate => 9600 ) ) {
             print "connected!\n";
         } else {
             print "sorry, no connection with serial port!\n";
         }
        */

        my %sig = $modem->status();
        for ('CTS','DSR','RLSD')
        {
                if($_ =~ /RLSD/) {
                        print "Signal DCD is: ", ($sig{$_} > 0 ? 'on'
: 'off'), "\n";
                } else {
                        print "Signal $_  is: ", ($sig{$_} > 0 ? 'on'
: 'off'), "\n";
                }
        }

The next thing to do was figure out a way to do this
in C. That was the hard part but I got there. Check
out the code in this page to interface with the serial
port on Windows and OpenBSD to recognize the pedal
presses.

Okay now we are halfway through. We can recognize
the pedal presses. But how to interface with the
audio player?

Before that we have an even more important question
to tackle.

Which player should we use?

I started working on audacity but quickly realized that
it does not have the rewind and forward feature. Plus
I realized that most audio players don't have this at all.
Except of course mplayer. But before that I considered
and rejected sox and vlc.

I looked at the mplayer input.c file, the way it interfaced
with the joystick and LIRC remote control. I know I could
copy the semantics and match it with key presses. I did the
project first on OpenBSD and then got it working under
Windows. It was a great project, I thoroughly enjoyed it.

All the code in beautiful syntax highlighted fashion with
black background is here

However the work is not over yet. You need to recognize
the pedal presses with more care. Right now it is too
sensitive so to speak. It has to have some back pressure
and hysteresis. I need to understand the needs of the
medical transcriptionist better. I shall finish this
project and add these details later. At the moment, I
can say that the project is nearly over.


Saturday, November 14, 2009

LiveUSB Image With OpenBSD

My programmer friend in India who is also a co-author on my
other blog has created two usb OpenBSD bootable images.
There is a 1Gb image and a 2Gb image. The instructions
and download links are at:

LiveUSB image with OpenBSD

Cheers!

Tuesday, November 10, 2009

Small Conky Calendar

I”m not a perl programmer and I’m sure my chances of having
come up with this on my own would be right up there with the
classic example about the monkeys with typewriters creating
the encyclopedia! :-) I got it off this mailing list:

freebsd-questions@freebsd.org

cal | perl -pe ’s/^/ /;s/$/ /;s/ ‘”$(date “+%e”)”‘ /\['"$(date "+%e")"']/’

I plugged it into the bottom of my .conkyrc file like so:

${color green}${execi 360 cal | perl -pe ’s/^/ /;s/$/ /;s/ ‘”$(date “+%e”)”‘ /\[ '"$(date "+%e")"']/’} ${color}

BTW, the above perl lines are wrapped, both the first which
is from the command line, and the second, which is the entire
line in .conkyrc. It shows the current day enclosed in brackets
in order to highlight it. Nice touch.

Cheers!

Labels: , , , , ,

Sunday, November 08, 2009

Taking Desktop Screenshots

I was Googling around the other night looking for graphics
help and ran across this site where I learned about some
X stuff I didn’t even know was there on my box:

Useful Things You Can Do with FVWM

Example of dumping the root screen using xwd, part
of the X Window System included with OpenBSD:
xwd -root -out file

Example of displaying the dumped image with xwud,
again part of the X Window System:
xwud -in file

Example of dumping the root screen & outputting it to
jpg format using xwdtopnm and pnmtopng, both
included in the netpbm port/package:

xwd -root |xwdtopnm |pnmtopng > file.jpg

Example of converting an existing screenshot taken with
xwd, using xwdtopnm and pnmtopng:

xwdtopnm < file | pnmtopng > file.png
xwdtopnm < file | pnmtojpeg > file.jpg


Example converting a screenshot taken with xwd with
convert, part of the ImageMagick port/package:

convert file file.png
convert file file.jpg


Cheers!

Labels: , , , , , , , , ,

Celebrate Freedom Nov 9 – Anniversary of the fall of the ‘Wall’

Nov 9, 1989. That’s the day the damnable Berlin Wall came down!
Celebrate freedom around the world today! Thanks, ‘Dutch’, I will
never forget your words:

“Mr. Gorbachev, tear down this wall!”

Cheers!

Conky Update

Added some information at the end of Conky System Statistics
on a new way to stop one version of Conky from a script that runs
from a cronjob and start a new version, again from a script run
from a cronjob. Hope if anyone used the old way they didn't have
the same problem I did. If so, sorry. The current way has been
working without issue for several days now.

Cheers!

Labels: , , ,

Sunday, November 01, 2009

Tweeting From the Command Line

Recently ran across an article Tweeting from the command line,
so I thought I’d give it a try. Didn’t have a Twitter account,
so that was the first step, creating one. Go to Twitter and
create your account.
After that, you need to copy the script and put in your username
and password and make the script executable. I placed my script
in ~/bin and did a chmod 700 ~/bin/tweet.sh so the script
is only executable, readable, and writable by me. Here’s the script:

#!/bin/sh

tweet="${@}"

user="username"

pass="sekret"

if  [ $(echo  "${tweet}" | wc -c) -gt 140 ];  then

     echo "FATAL: The tweet is longer than 140 characters!"

     exit 1

fi

curl -k -u ${user}:${pass} -d status="${tweet}"
https://twitter.com/statuses/update.xml >/dev/null 2>&1
if [ "$?" == "0" ]; then

echo "Successful tweet!"

fi

The full instructions are at the link listed above at
the beginning of this blog entry. It mentions escaping
special characters such as "?" and "!" for one thing,
and that’s important. I read the other night where you
can’t edit a "Tweet", only delete it, going on to explain
that anyone following you would not be in sync with your
Tweets if you deleted an entry and then entered a new
version of it. I erroneously thought, also, that to Retweet
meant doing a Tweet over, but it's actually more like
passing on what someone else has already Tweeted.
Obviously I've still got a lot to learn about Twitter, but
the script above should get my fellow CLI geeks going. ;)

Cheers!

Addendum:
TTYtter for Perl: More Tweeting from the command line


TTYtter: an interactive console text-based command-line Twitter client and Perl platform

Just a follow up on Tweeting from the command line.
Cool setup. ANSI Graphics, too. Check it out.


Cheers!

Labels: , , , , , ,

Saturday, October 31, 2009

ClamAv Update on OpenBSD Box

Updated my ClamAv today from version 0.95.2 to 0.95.3
and luckily read the warning about needing to patch it
on the download page at:

Clam AntiVirus

There’s a link there to download the diff. I downloaded
everything, then ran gpg against the file and signature
file to verify:

gpg –verify clamav-0.95.3.tar.gz.sig clamav-0.95.3.tar.gz

gpg: Signature made Wed Oct 28 10:59:38 2009 CDT using DSA key ID 985A444B
gpg: Good signature from “Tomasz Kojm ”
gpg: aka “Tomasz Kojm ”
gpg: aka “Tomasz Kojm ”
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 0DCA 5A08 407D 5288 279D B434 5482 2DC8 985A 444B


After that, cd /usr/ports/mystuff/ and do:

sudo tar xzvf /path/to/clamav-0.95.3.tar.gz

Next, I needed to uninstall the old version, but first I
had to stop the daemon running:
ps auxw grep clamd
sudo kill PID#


Then:

cd clamav-0.95.2
sudo ./configure
sudo make uninstall


There’s a warning in the docs about old librairies
and file versions on your system:

Caveats:

1) Make sure that you haven’t got old libraries (libclamav.so)
lying around your filesystem. You can verify it using:

$ ldd `which freshclam`
/usr/local/bin/freshclam:
Start          End            Type  Open  Ref  GrpRef  Name
1c000000  3c011000  exe     1           0       0              /usr/local/bin/freshclam
0470f000  24744000   rlib     0           1       0              /usr/local/lib/libclamav.so.6.5
022d7000  222db000  rlib    0           2       0              /usr/local/lib/libbz2.so.10.4
07d8b000  27d93000  rlib    0           2       0              /usr/lib/libz.so.4.1
0cd94000  2cd9d000  rlib    0           1       0              /usr/lib/libpthread.so.11.0
0c104000  2c13a000   rlib     0           1       0              /usr/lib/libc.so.48.0
05e7e000  05e7e000   rtld    0           1       0              /usr/libexec/ld.so


With my previous version of Clamav I had the file
/usr/local/lib/libclamav.so.6.4 but the uninstall
removed it okay.

More warnings:

2) Also make sure there is only one version of ClamAv
     on your system.

3) whereis freshclam

4) whereis clamscan


In case anything went wrong I saved my old configuration
files in /usr/local/etc renaming them. Then:

cd /usr/ports/mystuff/clamav-0.95.3/
cp /path/to/patch-0.95.3-bug1737.diff .
sudo patch -p1


After everything built and installed successfully, all that
was left to do was go back into /usr/local/etc and configure
clamd.conf and freshclam.conf, then restart the daemon:

sudo /usr/local/sbin/clamd

I want to stress like always that it pays to read
documentation. Where you want your TemporaryDirectory,
where you want your LocalSocket and DatabaseDirectory
and so on. Same goes for your freshclam settings.
READ THE DOCS!

If you’re going to go through all the above to have
Clamav on your system, then you’re probably going
to want to start it when your system boots. I’ve got
the following in /etc/rc.local:

if [ -x /bin/mkdir ]; then
/bin/mkdir /tmp/clamd && chown clamav:clamav /tmp/clamd
fi

if [ -x /usr/local/sbin/clamd ]; then
/usr/local/sbin/clamd
fi


I do the above mkdir along with the ownership thing
since my sytem cleans out /tmp on reboot. It’s set in
/etc/rc.conf.local:

clear_tmp_enable=”YES”     # clear /tmp on reboot

Cheers!

Labels: , , ,

Tracking Network Usage With a Shell Script

Every morning the daily output is waiting there for
me in my email. Part of the normal output under Ipkts
and Opkts shows what went through the interface:

Ipkts            Opkts
2999812      2509494

I don’t reboot very often but when I do, it seems the system
zeros this out and it starts all over again. I put together
a script that runs periodically from a cronjob:

#!/bin/sh
# Filename: netusage.sh

cd $HOME/bin
if grep ‘daily output’ $HOME/Mail/root/new/*; then
cat `grep -l ‘daily output’ ~/Mail/root/new/*` | \
grep xl0 |tail -1 |awk ‘{print $5}’ > ibytes.out
cat `grep -l ‘daily output’ ~/Mail/root/new/*` | \
grep xl0 |tail -1 |awk ‘{print $7}’ > obytes.out

else
echo “No daily output yet” > /dev/null 2>&1
fi
cd

At the end of the month I run another script to total
the network usage:

#!/bin/sh
# Filename: netusemonthly.sh
cd $HOME/bin
date > `date +”%Y%m%d”`_endofmonthnetuse.log
echo “” >> `date +”%Y%m%d”`_endofmonthnetuse.log
echo “Monthly Ibytes” >> `date +”%Y%m%d”`_endofmonthnetuse.log
cat *ibytes.out |awk ‘{ SUM += $1 } END { print SUM }’ >> \
`date +”%Y%m%d”`_endofmonthnetuse.log
echo “” >> `date +”%Y%m%d”`_endofmonthnetuse.log
echo “Monthly Obytes” >> \
`date +”%Y%m%d”`_endofmonthnetuse.log
cat *obytes.out |awk ‘{ SUM += $1 } END { print SUM }’ >> \
`date +”%Y%m%d”`_endofmonthnetuse.log
mv -f *ibytes.out *obytes.out rebytes/
mv -f *endofmonthnetuse.log rebytes/
cd

The file names I used probably look ludicrous and they are all
completely arbitrary. If you try this out you can use whatever
file names and paths suit your needs. The whole thing was done
just to learn more about scripting, awk, and so forth. Also, to keep
the numbers right after a reboot, I added the following to
/etc/rc.shutdown:

netstat -ivn |head -8 |tail -1 |awk ‘{print $5}’ > \
/home/useracct/bin/`date +”%Y%m%d%H:%M:%S”`_reboot_ibytes.out
netstat -ivn |head -8 |tail -1 |awk ‘{print $7}’ > \
/home/useracct/bin/`date +”%Y%m%d%H:%M:%S”`_reboot_obytes.out
chown useracct:useracct /home/useracct/bin/*reboot_*bytes*

Like I said, this was all done just for learning purposes.
Maybe you can find a way to use some variation of the idea
on your own system.

Cheers!

Labels: , , , ,

Saving Tips From Mailing Lists

Besides my constant experimentation towards always
learning more about OpenBSD, one of my other means
of accumulating tips is from the mailing lists I
subscribe to. I put together a script to save messages
from the misc@openbsd mailing list. It finds all the
messages in thread in my mutt subdirectory under Mail
and concatenates all of them to a text file. It’s
interactive and it asks you for a search pattern,
where to search, and where to save the output to.
Here’s what it looks like:

#!/bin/sh
# Filename: obsd2tips.sh – save mailing list problem
# questions and resolutions to my BSD tips folder

echo “Enter your search pattern: ”
read r

echo “Enter your search path: ”
read R

echo “Enter file to save to: ”
read i

cat `grep -l “$r” $HOME/$R/*` | \
sed ‘/Return-Path/,/X-Virus-Checker-Version/d’ >> \
$HOME/bsd/$i.txt

The stuff like Return-Path and X-Virus-Checker-Version
are stuff in my header I don’t want in the saved tip.
If it was just a single message I could strip the entire
header with a sed command, but it doesn’t work when there
is more than one message in the thread. It gets even more
complicated on the script I use to do the same thing with
my freebsd-questions mailing list threads. Here’s that
script and you will see the difference:

#!/bin/sh
# Filename: fbsd2tips.sh – save mailing list problem
# questions and resolutions to my BSD tips folder

echo “Enter your search pattern: ”
read r

echo “Enter your search path: ”
read R

echo “Enter file to save to: ”
read i

cat `grep -l “$r” $HOME/$R/*` | \
sed ‘/Return-Path/,/X-Virus-Checker-Version/d’ | \
sed ‘/freebsd-questions/d’ |sed ‘/unsubscribe/d’ >> \
$HOME/bsd/$i.txt

Depending on your MUA you will have to adjust your
filtering. I’ve been using mutt for years and do not
have any intention of switching to anything else. So,
if you’re using mutt, it will be easy to implement
for you. If you’re using some other MUA YMMV. ;)

Cheers!

Sat Oct 31 14:35:33 CDT 2009
Addendum:

Made the script a bit more interactive and helpful.
Thanks go to my friend Girish for helping me on it,
too. Here’s the new script for searching through my
misc@openbsd mail threads:

#!/bin/sh
# Filename: obsd2tips.sh – save mailing list problem
# resolutions to my BSD tips folder
found=”N”
while [ "$found" = "N" ]; do
echo “Enter your search pattern: ”
read r

echo “Enter your search path: ”
read R

echo “Enter file to save to: ”
read i

if grep $r $HOME/$R/* > /dev/null 2>&1 ;
then
cat `grep -l “$r” $HOME/$R/*` | \
sed ‘/Return-Path/,/X-Virus-Checker-Version/d’ >> \
$HOME/bsd/$i.txt
# XXX finish the program!
found=”foo”
else
echo “Can’t find it! Check your search pattern and path.”
# Rerun the search with new pattern and/or path
found=”N”
fi
done

I’d also like to add something at the end of the script where,
even after it finds what I’m looking for and writes it out to my
tips file, it will still come up and ask me if I’d like to enter
a new search. Anyone have a suggestion, please leave a comment.

Cheers!

Labels: , , ,

Sunday, October 18, 2009

Find and Kill Process

I had used the following to find an instance of conky and
kill it in order to start a different conky configuration:

ps -U useracct |grep justweather |head -1 | \
cut -c 1-5 |sed -e ’s/[\ ]//g;/^$/d’ > jwpid.out
kill -9 `cat jwpid.out`

That’s unnecessarily complicated compared to this simpler way:

ps -U useracct |grep justweather.conkyrc | awk ‘{print $1}’ | \
xargs kill -15

Labels: , , , , , ,

Thursday, October 15, 2009

Keeping Up With Security Patching

Put together a script that uses lynx(1) and sed(1) to download
and parse to a nice output the latest OpenBSD security and
reliability notifications.

#!/bin/sh
# Filename: undead.sh

cd $HOME/bin/
echo "" > errata.out
echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \
>> errata.out
echo "" >> errata.out

echo "Undeadly.org" >> errata.out
echo "" >> errata.out

lynx -dump http://undeadly.org/ ¦sed -n '/OpenBSD Errata/,$p, ¦ \
sed '/OpenBSD Resources/q' ¦ sed -n -e :a -e '1,3!{P;N;D;};N;ba' ¦ \
sed 's/^[ \t]*//' >> errata.out

echo "" >> errata.out
echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \
>> errata.out
echo "" >> errata.out

echo "OpenBSD Errata" >> errata.out
echo "" >> errata.out

lynx -dump http://www.openbsd.org/errata44.html ¦ \
sed -n '/OpenBSD\ FAQ/,$p' ¦ \
sed '1d ' ¦sed '/References/,$d' ¦sed '$d' >> errata.out

echo "" >> errata.out
echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \
>> errata.out
echo "" >> errata.out

cat errata.out ¦mail -s "OpenBSD Daily Errata" dennyboy

cd

You can always subscribe to security-announce@openbsd.org
but, sometimes, despite good intentions, things fall through the
cracks. In the end, at least IMHO, security is the responsibility of
the system admin, whether he's overseeing a server room full of
blade servers or if he's just a home user running one box.

Cheers!

Labels: , , ,

Monday, August 24, 2009

Your Favourite BSD Tips & Tricks?

Following from Dru Lavigne's blog:
A Year in the Life of a BSD Guru

Your Favourite BSD Tips & Tricks?: "BSD Mag has asked me to write another Tips & Tricks column for the upcoming 1/2010 issue of the magazine."

Labels: , ,

Sunday, August 23, 2009

Passive Aggressive Spam Filtering

Passive Aggressive Spam Filtering: "

Using OpenBSD and spamd for spam filtering and grey-listing is very old news but there are a few situations where it becomes politically and technically challenging to run in production. Here was a simple yet (and in no way the best method) of using PF and some friends on the internet to help 'slow the flow' of offal from the Internet into your mail server.

Read more..."

Labels: , ,

OpenBSD 4.6 Pre-Orders Online!

OpenBSD 4.6 Pre-Orders Online!: "

OpenBSD 4.6 cover

Pre-orders are now being accepted for OpenBSD 4.6, scheduled for release on October 1st, 2009.

The developers bring us an amazing amount of cool new stuff (PF now enabled by default, a new privilege-separated SMTP daemon, routing domain support and lots more).

Of course, t-shirts and posters are available too. Order your set NOW!

"

Labels: ,

BSD load demystified

BSD load demystified: "

Ariane van der Steldt (ariane@) posted a reply to the OpenBSD misc mailing list last month that offered some valuable insight into how load is calculated in the BSD kernel. This is a topic that comes up routinely but remains largely misunderstood by the average user.

Read on for Ariane's explanation and comparison to Linux load...

Read more..."

Labels: , ,

SecPuffy:): OpenBSD tips and tricks - adding swap on the fly

Monday, August 10, 2009

Spam control with OpenBSD greylisting

New link for my friend in Tamil Nadu. He's renamed
his antispam product to SpamCheetah. He has been a
good friend over the years, helped me numerous times
with OpenBSD and other projects, and definitely knows
what he's doing. So if you're in need of an antispam
solution, he's definitely the guy to see! The link is
in the title but here it is again just to be safe:

SpamCheetah - Main Site
SpamCheetah - On SourceForge

Youtube videos about the product:
OpenBSD Tarpit
SpamCheetah's Web Interface

There is both a commercial version with full tech-support and
the free downloadable open source version.

Labels: , , , , , ,

Saturday, May 16, 2009

Youtube Without Flash


Check it out:

HQTube for Greasemonkey

Youtube live streaming without flash, gnash, etc. Yes, it works,
at least so far in Seamonkey for me. Haven't tried it yet with
Firefox but, going from past experience, Firefox is easier to
work with than Seamonkey and better supported in regards
to add-on's, but I choose Seamonkey because it's just faster.
At least it always has been for me.

Audio is working great, no stuttering or distortion, and video
streaming over my broadband connection is good, no jerkiness
or distortion there either.

Before doing anything else, if you don't have them installed
already, install the mplayer and mplayerplug-in packages.

Whether you're using Firefox or Seamonkey, you'll need to
install Greasemonkey. For Firefox, check out:

Greasespot

If you're using Seamonkey, you'll have to install xsidebar.
You can get it at:

xSidebar :: Seamonkey Add-ons

Then you can get the Seamonkey modified Greasemonkey
version at:

mozdev.org - xsidebar: modifiedmisc: Greasemonkey

Here's what's in my ~/.mplayer/mplayerplug-in.conf:

vo=gl
cachesize=512
cache-percent=5
profile=plugin

Here's what's in my ~/.mplayer/config:

[plugin]
autosync=0
mc=0
correct-pts=yes

Those are straight out of the installation instructions for the
HQTube for Greasemonkey script. So far I haven't had
to change that or add anything else.

Caveat:
Right now the script only works with Youtube.

Sun Nov 1 02:13:41 CST 2009
Addendum:


Had to stop using HQTube. Started getting error messages saying
it was no longer compatible and needed upgrading. Unfortunately,
I couldn't find an upgrade. So, I did some searching and ran across
the following:

Free Youtube! for Greasemonkey

So far it's not working too badly in this old Seamonkey version I'm
running. Lazy old me, I haven't upgraded yet to OpenBSD 4.6 but it
is going to happen shortly. Already received my shiny new CD set! ;)
Only problem with Free Youtube! I've had so far is it doesn't want to
play the videos on the BSD Conference part of Youtube. Wouldn't you know
it? They seem to be laid out differently than regular Youtube videos.
Hopefully after I upgrade I'll get that going too.
Had to uninstall HQTube. Started getting error messages that

Labels: , , , , ,

Friday, November 14, 2008

Customizing Seamonkey's Toolbar

How to Customize the SeaMonkey Toolbar | eHow.com

I thought this had some pretty good tips in it
for Seamonkey, which is my favorite browser.
Much faster than Firefox, at least in my browsing
experiences.

Wednesday, July 09, 2008

SSH & Samba Write-up

I solved a windows network connectivity problem I was
having when I was using a socks 5 proxy through an ssh
tunnel to my OpenBSD box for safer browsing. I'd leave
the windows box running but not use it, sometimes for
hours, and more often than not, overnight. When I'd try
to get anywhere with the browser I no could. I still had
connectivity with the OpenBSD box, but that was it. I put
in a batch file that cleans up the local area connection
on the windows box and run it from windows scheduler
every 6 hours and it solved the problem. The addendum,
batch file, and link to the network article that helped me
are at the bottom of my original write-up at:

SSH & Samba

Labels: , , , , , ,

Friday, July 04, 2008

Fluxbox Article

I've got a new write up on switching desktop wallpaper in
fluxbox automatically on a scheduled basis by using a script
and a cronjob to call it. I also made some additions to my
.kshrc file exporting some values into the environment for
when I login to the system that can be tested against and
also tell fluxbox which one of my wallpaper files to load
when it's starting.

Fluxbox Desktop

Labels: , , , , , , , ,

Saturday, May 31, 2008

Recent Web Site Updates

I finally got a couple of pages up I'd been wanting to
despite a bunch of interruptions. One is on installing
and configuring Conky to display system info on your
desktop. It also shows how to pull in other information
like weather reports and some system info that I couldn't
get with Conky's regular functions, due to either my own
misunderstanding of the instructions, or else something in
my chipset that's incompatible with the program. Probably
some of both.

ADDENDUM: 2008-06-06
Pertaining to Conky above, I've added some info to the page
that shows how I'm now getting stock market data to display.

ADDENDUM: 2008-06-13
Again, pertaining to Conky above, added some info on how I
kludged together a script to filter out my daily Accuweather
forecast email message, format it and scp it from that box to
the box I'm using conky on to be displayed below the current
conditions feed I get from NOAA's weather site.

The other write up is on creating a file to be used as a
persistent table for OpenBSD's PF packet filter firewall,
how to automatically concatenate IP addresses of would
be intruders to the file using scripts that run on a schedule
from a cronjob, and then flush the one table that does the
collecting and reload the persistent file back into its own
table. This makes it truly persistent, since rebooting has no
effect. You don't have to start back all over again with loads
of intrusion attempts in your logs.The pages are at:

Conky
PF with a Cumlative Table

ADDENDUM: 2008-07-04
Again I've added some more to the conky article above.
This addition describes how I run 2 instances of conky
and change one of them depending on the time of day and
the day of the week, since one configuration uses stock
market data and weather, while the other for the times
when the market is closed just displays the weather.
The change is accomplished using 2 short shell scripts
and 2 cronjobs. The last part of the entry shows how I
clean stale values from the environment in case I close
X but don't log out of the system, and then restart X.
From the value that gets exported from .xinitrc conky
determines which configuration file to use by comparing
that value with a small text file containing appropriate
times to load the file with stock market data. If it's
after hours or on the weekend when X restarts, it loads
just the weather version of conky on the one side of the
screen. The other conky running on the right side of the
screen doesn't change. It always shows system information.

Labels: , , , , , ,

Tuesday, May 06, 2008

4.3 Upgrade & New Pages on Web Site

4.3 OpenBSD is out and I've got one box upgraded so far. Had a
couple of problems which you can read about at:

Denny’s OpenBSD Newbies blog

Should be clear to see they were my fault. :-)

I also put up a couple of new pages under the tips & tricks section.
One on using colors in xterm and one on quick remote printing over ssh.

Xterm and Color

Quick Printing Over SSH

Labels: , , , , , , ,

Wednesday, April 16, 2008

New Page on Web Site

Added a new page on my web site pertaining to using external
mailto links in Firefox with older text email programs like
mutt and pine. You can read it at:

Firefox and External Mailto Links

Only a couple of weeks until OpenBSD 4.3 is released! Yay! Time to do the upgrade dance. Only thing I hate doing is messing with
nut on my one box. Took me a long time to figure it out. Even
after I thought I had it right, turned out I didn't and I had to do
some more reading and work on it. I've put off upgrading from
4.1 to 4.2, partly because of the libexpat issue, but mostly from
laziness and taking advantage of of the OpenBSD development
team's kindness in providing security patches back 2 release
versions. I'd say that last reason probably makes up 90% of my
reason for being an upgrade laggard. :-)

I've had good success in getting pf and ssh working well with
my windows box and also with pure-ftpd. I especially love
the bruteforce rule capabilities!

That's it for now. Stay safe, stay secure. Use OpenBSD. That'll
take care of most of your security right there!

Labels: , , , ,

Monday, March 24, 2008

Three New Pages on Web Site

Saturday, February 23, 2008

Web Site Update

Finally made good my threat and added a new page on using
SSH, Samba, and Cygwin on Windows to forward ports for secure
browsing, file management, and so forth, from Windows boxen
to OpenBSD boxen. Includes a howto on generating passwordless
SSH RSA keys which is what I believe is safer than typing in
cleartext passwords. Page is at:

SSH & Samba

I also added a link to a site where you can pick up binary updates
for OpenBSD. When I checked it there were currently 3 available,
4.0, 4.1 and 4.2. Here's the link again:

Binary Updates for OpenBSD

powered by performancing firefox

Labels: , , , , , ,

Wednesday, February 06, 2008

My Web Site Server Error Messages

I ran into the familiar "Forbidden You don't have permission thing"
myself the other day when I was testing links for typos. All I can
say is, there must've been a server problem at the time. As soon
as I got the message about it happening to someone else, I tested
the links again from this blog and they're all working. So that's
why I say it must've been a server problem. If anyone experiences
this again, please leave me a comment. I certainly want it to be
accessible to to all visitors.

powered by performancing firefox

Labels:

Monday, February 04, 2008

Updates

I updated my blog entry of Saturday, September 01, 2007 titled
"More Multimedia" pertaining to some things I found recently
to help when you get errors using mplex to recombine *.m2v and
and *ac3 files together again for final mpeg output. Includes a link
to the article at:

http://polarwave.openbsd101.com/dvd.html

powered by performancing firefox

Labels:

Thursday, January 24, 2008

Web Site Updates

I've put up some new stuff on the web site.

  • New feeds at Feeds Page
  • New entry on Blog about Samba and Firefox over SSH.

powered by performancing firefox

Labels: , , , ,

Monday, January 07, 2008

Recent Web Site Update

I was reading an article by Dru Lavigne at:

Hack #51. Get the Most Out of FTP

I used the info on .netrc along with a script I put together to
login anonymously automatically, get a directory listing of the
packages and diff it against a earlier existing directory listing
in my home directory to see if any packages had been updated.
It was fun as I went along, learing more about scripting and
command line ftp.
More Packages

powered by performancing firefox

Labels: , , , ,

Wednesday, January 02, 2008

New Updates on Web Site

Added some pages to the new web site. There's help there on
vim, mutt, getting help on OpenBSD mailing lists, NTPD, dump
and restore, working with packages, and a page on scripting
help and .profile aliases to keep from opening the same program
twice.
Polarwave's Tips & Tricks

powered by performancing firefox

Labels: , , , , , , , ,

Wednesday, December 19, 2007

New Subdomain

Well, it's not my own domain, but a subdomain serves the purpose
and was a very nice gesture of the owner of the domain. I've begun
putting up tips and tricks for newbies there for OpenBSD. Going to
be some work and will take time, but time I got. Now money, that's
another story. :-) Site is at:
http://polarwave.openbsd101.com

powered by performancing firefox

Labels:

Monday, September 17, 2007

Maintenance Scripts

These probably aren't the most professional system maintenance
scripts ever written, but they get the job done. The first one,
logroll.sh, does just what it says. It rolls over my procmail
and getmail logs, saving them with the date appended and starts
a new log like so:

#!/bin/sh
#
# Script to rotate ~/.procmail/.procmail-log and
# ~/.getmail/log every week so they don't start to
# take on huge proportions.
#
cp ~/.procmail/.procmail-log \
~/.procmail/`date +"%Y%m%d"`.procmail-log.txt
#
echo > ~/.procmail/.procmail-log
#
cp ~/.getmail/log ~/.getmail/`date +"%Y%m%d"`.log.txt
echo > ~/.getmail/log

There's a harder way which I tried first, not thinking, where
the log is copied with the date appended, then delete the log,
then recreate with touch, then chmod to 0600. Lot of work and
unnecessary. All you have to do is copy it with the date and
then echo nothing into it like 'echo >'. Still the same file
as before, just nothing in it, starting over fresh.

The next one is for root, to backup changes in /etc and /var/db
without having to do a dump, just using rsync:

#!/bin/sh
#
# Weelky rsync changes in /etc/ & /var/db to /data2/backups
#
/usr/local/bin/rsync -arvvgt /etc/ /data2/backups/etc && \
/usr/local/bin/rsync -arvvgt /var/db/ /data2/backups/db/

The double 'vv' is for very verbose to give lots of info.

The last script's comments make it pretty self explanatory.
Just a way to keep track of what you've installed lately.

#!/bin/sh
#
# Script lists /var/db/pkg & outputs it to a file with
# the date appended. Then it diffs it against the previous
# list from the week before & outputs the differences to a
# separate file with the date appended. Then it takes the
# most recent list wth date appended & copies/overwrites
# the previous weeks listing to be current.
#
cd /data2/backups
ls -al /var/db/pkg > `date +"%Y%m%d"`pkgs.txt
diff pkgs.inst.list.txt `date +"%Y%m%d"`pkgs.txt > \
`date +"%Y%m%d"`chgs.txt

mv pkgs.inst.list.txt `date +"%Y%m%d"`previous.week.pkgs.txt
cp `date +"%Y%m%d"`pkgs.txt pkgs.inst.list.txt

powered by performancing firefox

Labels:

Sunday, September 16, 2007

CUPS Printing Problems

Been a rough week and a half. For a long time now I just
used OpenBSD to print mostly plaintext documentation to
a windows shared printer. Now I'd like to be able to print
other stuff too. Graphics, web pages, etc. I installed cups,
samba, and pnm2ppa which built okay on my system but it's
not included in the ports and packages. I downloaded it
from http://www.superbhosting.net/sourceforge.php and built
it on my OpenBSD 4.1 box. I already had foomatic-rip and
foomatic-gwrapper in /usr/local/bin so I renamed them to
stop any confusion, since cups installs foomatic-rip when
you install it cups. I finally figured out how to print to
my windows shared printer with it, but that was just the
tip of the iceberg. I couldn't stop the shearing problem
no matter what I tried when I'd try to print a web page.
And, it was running off the bottom of the page despite the
fact I had it set for letter, not a4 mode. I finally went
into firefox's page setup, unchecked the box that says to
fit to page, and manually set it to 75 percent, and told
it to print images and colors. Also, when you configure
cups from the browser interface at localhost:631 under the
printer options section, I told it to use the ordered mode
under the dithering algorithm instead of Floyd Steinberg
which promises higher quality, and set the bidirectional
printing to on for faster speed, although it says without
it you'll get better quality. Now I'm still getting some
shearing on some letters, but not too much. When I print
just a text web page like at the rfc web site, it comes
out pretty good. I'll have to learn how to do more stuff
with it from the command line. Maybe I can tweak it some
more. I downloaded a new HP-DeskJet_722C-pnm2ppa.ppd for
pnm2ppa to use for my 722C printer. The cupsd daemon man
page says the default is to run in the background as a
daemon, so all I added this to /etc/rc.local:

if [ -x /usr/local/sbin/cupsd ]; then
/usr/local/sbin/cupsd
fi

And, to run samba as a daemon, I added:

if [ -x /usr/local/libexec/smbd ]; then
/usr/local/libexec/smbd -D
fi

if [ -x /usr/local/libexec/nmbd ]; then
/usr/local/libexec/nmbd -D
fi

That did the trick. They start up fine on boot. Anyone
reading this who has some experience with the shearing
problem with cups, foomatic-rip, and pnm2ppa, please
share it if you have time. That's it for today.

powered by performancing firefox

Labels:

Saturday, September 01, 2007

More Multimedia

DVD Ripping and Burning Tips

I usually use 1 of 2 methods for finding out
what's on a dvd. First, I run

lsdvd

to see how many titles and chapters are on the dvd,
and I look for the main title. More often than not,
it's the first one, but not always. Good example was
one I ran across that had five 24 minute episodes and
then one large file with all 5 in it. When I played
the dvd with mplayer, I saw on the menu you could
choose each individual episode, or you could choose
the menu listing 'play all'. The combined file was
too large for a single-layer dvd, but I could rip each
individual episode and put 3 on one dvd and the other
2 on a 2nd dvd. Here's how I did it, starting with
episode 1:

mplayer dvd://1 -dumpaudio -dumpfile episode1.ac3
mplayer dvd://1 -dumpvideo -dumpfile episode1.m2v
mplex -f 8 -o episode1.vob episode1.ac3 episode1.m2v

So, in the above scenario, title one was just one episode,
not the main movie file with all the episodes in it.

The other program I use to check the dvd is streamanalyze,
part of the streamdvd package, which includes lsdvd, at
least in the OpenBSD version of it. Do this:

streamanalyze -i /dev/rcd0c -t 1
(assuming title 1 is the main title)

That'll show you what's in title 1. File formats look like:

Videostream id's always start with '0xen' where n is the
track number. In most cases a video dvd contains only one
video stream '0xe0' but multiangle videos might contain
more video streams.

Audiostream id's always start with '0x8n' where n is the
track number. Most video dvd's contain multiple audiostreams
in different languages, director comments, etc. There's a
special case for mpeg audiostreams that are pretty rare for
find. If you have a dvd containing mpeg audiostreams and want
to select one of them, use '0xcn' as an identifier where n is
the tracknumber (also special, counting starts from 1).

Subpicturestream id's always start with '0x2n' where n is
the track number. Most video DVDs contain multiple subpicture
streams in different languages.

The above info on streamanalyze and streamdvd can be found
in readme files installed with the programs. On my OpenBSD
box, the readme are in:

/usr/local/share/doc/streamdvd/README.streamanalyze
/usr/local/share/doc/streamdvd/README.streamdvd

* NOTE *
You can use streamdvd to rip and shrink a dvd movie, but be
forewarned, YMMV! I did okay with it on smaller movies, and
even on shrinking some larger ones, but when it came to
extracting particular streams rather than just everything, the
program choked up on me more often than not. It may have
something to do with the way it interfaces with dvdauthor:

dvdauthor -t -o /path/to/save -f 'streamdvd -i /dev/rcd0c \
nbsp&;nbsp&;nbsp&;nbsp&;-t 1-s 0xe0,0x80,0x20 -c 1-9 |'

That's a good example. It's trying to get title 1, the main
video, the first audio, and the first subtitle, chapters 1
through 9. That's what the docs say. But, it always seems to
run into problems. That's why I turned to mplayer in the first
place.

Before leaving this section, tcprobe deserves mention. It's
part of transcode but can be used independently for medium
and print information. The command

tcprobe -i foo.avi
will print interesting information about the avi file itself
and its video audio content. It has some interesting switches
you can tack ontothe command. As always in the 'nix' world, try

man 1 tcprobe. Yep, READ THE FINE MANUAL! ;)

Before doing any ripping, if you see the main title is really a
whopper, like 8GB or so, you can rip the movie in 2 parts with
mplayer. Let's say

lsdvd reports there are 24 chapters in the main title. To split
the dvd:

mplayer dvd://1 -chapter 1-12 -dumpstream -dumpfile movie1st.vob
mplayer dvd://1 -chapter 13-24 -dumpstream -dumpfile movie2nd.vob
But, if you see your movie will fit on a single-layer dvd, or
that it looks close anyway, just do this:

mplayer dvd://# -dumpstream -dumpfile movie.vob

To play the movie with english subtitles, do this:

mplayer -sid 0 movie.vob

If your movie won't fit on a single-layer dvd, but it doesn't
look too awfully big, after you've ripped it, do the following:

Extract audio:
tcextract -i movie.vob -t vob -x ac3 -a 0 > audio.ac3

Extract video:
tcextract -i movie.vob -t vob -x mpeg2 > movie.m2v

If you need subtitles use spububmux from dvdauthor and ifo_dump
from libdvdread-utils. Check for color palette:

ifo_dump /dev/rcd0c 1 |grep Color |sed 's/Color ..: \
00//' > palette.yuv

Generate picture PNG in format 4.12
spuunmux -s 1 -p palette.yuv movie.vob
This command generates PNG files and command file sub.xml
Calculate the exact shrinkage factor with this formula:
requant_factor = (video_size / (4700000000 - audio_size)) * 1.04
* NOTE: This worked perfectly for me first time out. YMMV *

Now use the factor derived from the formula above to
shrink the video:

tcrequant -i movie.m2v -o new.m2v -f (shrinkage factor)

*NOTE*
From everything I've read on shrinking, you shouldn't
go larger than a 1.5 factor. It degrades the quality too
much. If after running the formula above you find the
factor exceeds 1.5, you should probably split the movie.

Now recombine new.m2v with the audio file audio.ac3:
mplex -f 8 -o new.mpg new.m2v audio.ac3

*UPDATE*
There's a newer version of this article up on my web site
with additional information about how to handle mplex errors.
I think it comes about because of the newer copy protection.
I know when I first added this article to my blog, I wasn't
having those sort of problems with mplex. I could be wrong,
though. Feel free to leave a comment. When you get to the page,
search for "Nasty DVD's". Article is here:

DVD's - Analyze Rip Burn

At this point, you can insert subtitles.
spumux sub.xml < new.mpg > new.vob

Now that you've got your movie ripped and/or shrunk, you
setup the dvd file structure with dvdauthor. First, create
dvd.xml and name it whatever you want. Just be sure to have
an .xml extension

<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="new.vob" />
</pgc>
</titles>
</titleset>
</dvdauthor>

Pass the xml file to dvdauthor for authoring:
dvdauthor -o /path/you/saved/to -x dvd.xml


Dvdauthor creates 2 subdirectories below where you're at,
AUDIO_TS & VIDEO_TS. Let's say you're in /data/dvdfiles.

* NOTE *
I don't know if I can stress the value of dvd rewritables
enough! Catch some on sale and get them. They'll save you
coasters and frisbees, for sure. I got some half-priced
recently by watching the Sunday ads. Of course, you can
take your changes on eBay. I haven't run into hardly any
problems in three years. 'X' Those are crossed fingers. ;)
Anyway, here's some info on rewritables:

To blank a dvd-rw that already has been written to, and
really wipe everything off of it, do:

dvd+rw-format -blank=full /dev/rcd0c

That does a full blanking. This will take about one hour
on 1x media. A fast blanking can be done by:

dvd+rw-format -blank /dev/rcd0c

On to the burning.

To create an image to burn, do this:

mkisofs -dvd-video -udf -o new.iso /data/dvdfiles/

To burn the image, do this:

growisofs -Z /dev/rcd0c=new.iso

To skip the last 2 steps & burn directly to dvd, do this:

growisofs -dvd-compat -dvd-video -udf -Z /dev/rcd0c \
/data/dvdfiles
(Assuming /dev/rcd0c is your burning device and
/data/dvdfiles is theoutput directory of dvdauthor)

or, for the directory containing AUDIO_TS and VIDEO_TS:

growisofs -dvd-compat -Z /dev/rcd0c -dvd-video .

(and don't forget the . on the end)

* NOTE on burning devices *
On other 'nix' type systems, your burning device might be and
probably is something other than /dev/rcd0c but I'm writing as
an OpenBSD user, and that's what my device is.

gopher://sdf.lonestar.org/00/users/dancer68/multimedia/
dvdripping.txt.txt
(the double extension's NOT a typo)

As a side note, here's an alternative to streaming with vlc using
nc or netcat:

On your streaming client, type this first:

$ nc -l 1234 | mplayer -cache 8192 -

Then walk to your streaming server and push the file
down the network's throat.

Filename is just an example.

$ cat Aerosmith-Amazing.mpg | nc 192.168.1.5 1234

If the streaming client IP is 192.168.1.5...

That is all. It works. Really cool. :)

If you're on the client end, you could still use vlc to do
the same thing I just outlined with vlc to save the stream.

Some links that helped me:

http://www.brandonhutchinson.com/Burning_Video_DVDs_
in_Linux.html

http://www.ericdugas.com/howtos/ripDVDWithMplayer/
ripDVDWithMplayer.php

http://www.dizwell.com/prod/node/47

http://forum.freespire.org/archive/index.php/t-2978.html

http://www.linuxquestions.org/linux/answers/Applications_GUI_
Multimedia/DVD9_to_DVD5_guide

http://wiki.videolan.org/index.php/VLC_command-line_help

http://digg.com/software/How_to_Rip_DVDs_with_VLC

powered by performancing firefox

Labels:

Sunday, August 19, 2007

Drive Free Space Script

I originally got this script from:

http://64.233.169.104/search?q=cache:aIS0abHfbL4J:
techrepublic.com.com/i/tr/downloads/home/
milton_ingram_scripts.pdf+milton_ingram_scripts
&hl=en&ct=clnk&cd=1&gl=us&lr=lang_en&client=firefox-a

That's in html for convenience. There's also a pdf file:

http://techrepublic.com.com/i/tr/downloads/
home/milton_ingram_scripts.pdf

I changed it around a little. My way reads in gigabytes and I
dressed up the right side under 'Mounted on' to align left to
make it neater and look like the regular output of df.
You'll have to play around with the heading spacing on
Filesystem, Total, Used, and so forth. I'm no good at
html and besides, the formatting of this template on
my blog wouldn't allow the lines to appear as they do
in the script anyway. For instance, the ==== lines have
29 cut off the end to make it fit here. Any questions, I
can always send the script to anyone interested. I just
liked it since it helps me keep track of how much free
space I have.

#!/bin/ksh
# Generate a readable disk free listing
# MWI 0310
#
echo "======================================= "
echo "File System Report in GB :" `date`
echo "======================================= "
echo "Filesystem Total Used Avail Capacity Mounted on "
echo "======================================= "
df -k | sort -k6 |awk '$1!="swap" && $1!="Filesystem" \
{tt+=$2;tu+=$3;tr+=$4;printf "%-9s %10.2f %10.2f %10.2f %9s \
%-13s\n", $1, $2/1048576, $3/1048576, $4/1048576, $5, $6} \
END{printf "\nTotal GB %10.2f %10.2f %10.2f\n", tt/1048576, \
tu/1048576, tr/1048576 }'
echo "======================================= "

powered by performancing firefox

Labels: