puflogh300X74.gif

Polarwave's OpenBSD
Tips and Tricks for Newbies

| Fun |

| Home | Tips and Tricks | Links | News Feeds | Contact | Blog (Opens in New Page) |


Fun

Working too much lately, time for a little fun. ;) Over the last few years, when time
permitted, I made some of my own fortune files. Some are short, only fifteen or so
entries. Others, like the quotations of Ralph Waldo Emerson, which has quite a few.
Fairly large fortune file. The file names are all pretty much self-explanatory as to
their content. If not, well, life's a mystery anyway, right? ;)

Incidentally, you can do other stuff with them besides put them in your ~/.profile
or ~/.kshrc file like so:

[ -x /usr/games/fortune ] && /usr/games/fortune /usr/share/games/fortune/groucho
I use mine on one OpenBSD box with mutt for a random signature. In my .muttrc file,
I have:
set signature=~/muttsig.sh|
The muttsig.sh file which looks like this:
#!/bin/sh
#
echo
fortune /usr/share/games/fortune/definitions && cat ~/fingerprint.txt
Comes out looking like this:
Be alert. The world needs more lerts.

===============================================================
GnuPG key : 0x1644E79A | http://wwwkeys.nl.pgp.net
Fingerprint: D0A9 AD44 1F10 E09E 0E67 EC25 CB44 F2E5 1644 E79A
===============================================================
The fingerprint.txt is just a fingerprint from my gpg public key I plug into all my messages.
You can put whatever you want in there. And, don't forget to chmod the signature script
to executable. Anyway, below is a list of some of my fortune files. Each one is in a *.tgz file.
Just download it and extract the two files inside to wherever you keep your fortune files.
OpenBSD fortune files are usually in /usr/share/games/fortune. Have fun!

Table of Contents:



Killmyself.c

I mentioned this program in the site blog earlier when I introduced Girish Venkatachalam,
my friend in Tamil Nadu, who is now a co-author on the blog. Girish wrote the program
for me after I complained I was killing myself, trying to figure out how to start and stop
recording a radio program I like using mplayer from a cronjob. He appropriately named
the program killmyself.c in his own witty way. :-) I've put the code in here since it's open
source like all Girish's programs, along with an example of how to use it.

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/time.h>

extern char *__progname;

/* This program self destructs after a specified time */
int main(int argc, char **argv) {

	int ret;
	long minutes;
	struct timeval t, t2;
	pid_t child;
	if (argc < 3) {
		printf("Usage: %s <minutes> <mplayer arguments> \n",
				__progname);
		exit(128);
		/* NOT REACHED */
	}


	if ( (child =  fork()) != 0) {
		/* I am the parent process */
		minutes = strtol(argv[1], NULL, 10);
		sleep(60 * minutes);


		/* I am done! */
		kill(child, SIGINT);
		exit(0);

	} else {
		/* I am the child */
		execv("/usr/local/bin/mplayer", argv + 1);
				
		exit(0);
	}
} 

Just copy the code to whatever file name you want, compile it with gcc and chmod it to
executable. Run it from the command line with whatever address you're streaming from,
from a script, or, like I do, from a cronjob that calls a script like I do:
59 16 * * 6 $HOME/phc.sh > /dev/null 2>&1
Putting ' > /dev/null 2>&1 ' on the end tells it not to notify you by email. If you want to
be notified, you just take that part off the cronjob command. The script that it calls looks
like this:
#!/bin/sh
#
~/killmyself 122 -dumpstream mms://radio.mpbonline.org/MPB_Live -dumpfile \
/data2/dennyboy/garrison/mp3/show/`date +"%Y%m%d"`phc.mp3
The 122 integer after the initial killmyself command is in minutes. I always tack an extra
minute on each end of the cronjob in case the show doesn't start exactly on time sometimes
which has been my experience in the past, especially on NPR. The -dumpstream switch does
just that, dumps the stream from the address that follows it. The -dumpfile switch dumps
the stream to phc.mp3 with the date prepended to it using `date +"%Y%m%d"` so I can
keep track of my files and not overwrite anything either.

I always validate all my web pages and the validator wasn't happy with all the symbols in the
C programming code on this page even though I enclosed it all with the pre tag, so I replaced
all the symbols with html entity codes. Now the page passes validation and displays okay for
me in Firefox, Seamonkey, Internet Explorer, and also in Lynx. If and when you copy the code
for yourself, just copy and paste it from the displayed page. If you right click and choose view
source and copy that, you're definitely going to run into problems when you try to compile it.

So, try it out. Record your favorite radio program, news, whatever, for later listening. Like
I've told so many of my "Windoze" friends, OpenBSD isn't just for geeks, propellor heads,
network admins, or servers. You can have fun with it, too! Enjoy! :-)

Homemade Wallpaper

Had some fun with this one. I have quite a few BSD related wallpapers I've made, but I like
this one the best.

greendragon_thumb.jpg

You can download the file in either jpg or png format:

dragonobsd1024x768.png
dragonobsd1024x768.jpg

Home

Delicious Bookmark this on Delicious

No affiliation between this site and the OpenBSD project exists or is implied.

valid-html401.png

Hits Counter
[ 1124 ]