freebsdman – script to display ‘man’ pages from

Hi friends,

I love FreeBSD’s Documentation(FreeBSD too), Its one of the top class documentations available for UNIX. I think they are capturing nearly every thing about UNIX.

Previously I’ll go to their man page site “”, give the command name and get the man page whatever format I want(pdf is damn good!!). But I thought It will be useful if I have an alternative to that *crap* man command in my ‘Ubuntu’ so that I can get all the ‘man’ pages available for Entire Unix family.

Somewhere I saw a small script which gets input from user and generating a URL with GET method parameters and connecting with the server using ‘curl’. Then I decided to do the same thing with my freebsd server, here is the result, a script which will get command name and display the man page, it can be used to get the pdf document also.

        freebsdman [-a 0|1] [-s section] [-d distro]
                [-f format] [-o] [-h]

        -a 0|1          do 'apropos' search(1-enable, 0-disable)
        -s section      select man section(1-8)
        -d distro       distribution name
        -f format       appropriate format
        -o              list available values for other options.
        -h              print this help

        $ freebsdman ps
                will display man page of 'ps' command from latest
                FreeBSD version in terminal(format: ascii).

        $ freebsdman -d 'solaris' -f pdf mpstat > mpstat.pdf
                will generate 'mpstat.pdf' file which contains
                manual page of 'mpstat' from solaris.

        $ freebsdman -o
                will list all valid values for 'freebsdman' options.

        $ freebsdman -d 'x11' X
                will display 'X' manual (note: manual will not be displayed
                without -d 'x11' option)

Download: freebsdman

One day I’ll have FreeBSD in my Lappy :)

attachlicense – script to add license into the source files

Hello mates,

Its has been some kind of twisted weekend to me, Not enough time to post, But I got some time with my lappy to create a script which will automatically add my license text,  Yes, its like the previous post, but this one is a bash script, instead of vi script(Ooh, its a damn interesting to do vi scripting.. defenately I’ll try something new with it).

Here is the script,


And here is my customized gplv2,

* <description>
* Copyright (C) <year>  <name> <email>   
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see .

This script will not attach if it see a keyword already present in the source file, so forgive me to put this stupidity in place, I just wrote it for no purpose, I need to update this script to do more, but don’t have enough time to do it. To attach the license to a list of .c and .h files, all you need to do is,

$ find "${MYDEVDIR}" -name '*.c' -o -name '*.h' | xargs attachlicense -f gplv2.txt -n 'Mohan Raman' -e '' -w -v  

I just showed only two options, there is more options to customize,

Finally, its just for fun script, and not yet fully completed, so please don’t try this with production sources, also if you have suggessions, let me know.


Mail with Attachments (Unix shellscript)

Hi friends,

Lot of us already know howto send attachments in mails using shellscript. Lot of us already wrote these kind of script. Here is one more script to do the same thing. I already added all the details in the script itself. It is self explainable. If somebody wants, take it.

# - script to send mail with multiple attachments.
# Wrote By: me! mohan43u.
# Date: Thu Mar 06 11:56:12 IST 2009
# License: Its in public domain. Use it whatever way you can.

USAGE="USAGE: [-t tolist] [-s subject] [-e encodetype] 
	-t tolist	comma seperated e-mail addresses
				(Default: current userid).

	-s subject	Subject line (Default: 'test mail from

	-e encodetype	Encoding type (x-uuencode/base64). only GNU uuencode
			can encode in base64. If you are using this script
			in Old school unixes(solaris, HP-UX, AIX, etc) use
			only 'x-uuencode'. Linux can handle both types
			(Default: x-uuencode).

	-h		Print this Help text

This script will read standard input as a mail body and takes filenames as 
arguments to generate a preformatted mail content in satndard output. you can
simply pipe the output to any MTA (sendmail, postfix etc.,) to send a mail
with attachments.

	$ -t -s 'mail with attachments' file1 \
		file2 | /usr/sbin/sendmail -v -i -t
	hi foo,
		I attached file1 and file2 with this mail. Take a look at it.


	This above command line will attach file1 and file2 and send a mail
	to The files file1 and file2 will be encoded in
	'x-uuencode' and attached with this mail.

SUBJECT="testmail from script"
BOUNDARY="`date +'%G%m%d%H%M%S'`"

while getopts 't:s:e:h' OPTIONS
	case "${OPTIONS}" in
	t) TO="${OPTARG}";; 
	h) echo "${HELP}" && exit 0;;
	\?) echo "${USAGE}" && exit 1;;

SHIFT_COUNT=`expr "${OPTIND}" - 1`
shift "${SHIFT_COUNT}"

	echo "To: ${TO}"
	echo "Subject: ${SUBJECT}"
	echo "Mime-Version: 1.0"
	echo "Content-Type: multipart/mixed; boundary=\"${BOUNDARY}\""
	echo "Content-Disposition: inline"
	echo "User-Agent: 0.1"
	BASENAME=`basename "${1}"`

	if test "${ENCODE_TYPE}" = "base64"
		ENCODED_MESSAGE=`uuencode -m "${FILE}" "${BASENAME}" \
		| egrep -v '^begin|^='`
		ENCODED_MESSAGE=`uuencode "${FILE}" "${BASENAME}"`

	echo "Content-Type: application/octet-stream"
	echo "Content-Disposition: attachment; filename=\"${BASENAME}\""
	echo "Content-Transfer-Encoding: ${ENCODE_TYPE}"
	echo "Content-type: text/plain; charset=utf-8"
	echo "Content-Disposition: inline"

# Main

echo "--${BOUNDARY}"
echo "${BODY}"
	echo "--${BOUNDARY}"
	create_octet_part "${FILENAME}"
echo "--${BOUNDARY}--"

createpet script

Hi all,

After rearranging my partitions and installing puppy, I got tha hunger to build .pet packages one more time(Ya, I really enjoyed compiling and building pet packages using puppy through my pendrive). One mistake I did previously is, I didn’t put puppy into my hard disk. Yes, Its really a big mistake I did. It prevent me to interact more with puppy and diverted me to somewhere else.

But from last week, I’m always boot straight to puppy, from my experience, I would suggest, If you want real geekness, like how gentoo guys do, or how arc linux guys do, or how slackware guys do, then install puppy into your harddisk. Puppy is a perfect platform to do stuffs like compiling packages, hunting for dependencies, rebuilding, packing stuffs.

While using puppylinux, I felt that I’m missing my favourite browser, yes, firefox. So I download the source and started compiling, knowing that it will ask for different libraries, I fullfilled all the gaps by downloading and compiling the dependencies and finally got firefox 3.0.6 running in puppy 4.11.

To create packages, puppy have two scripts, one is new2dir and dir2pet. I used them on beginning, and lost interest with them. They are not giving enough flexibility to create .pet packages, So I went through dir2pet package and noted down what all files that script creating.

Then I started my own script to create .pet package from DESTDIR directory. After some initial testing I started to use createpet to create .pet packages. Here are the steps you need to do to create .pet package from source tarball using createpet script,

$ tar xvzf package-version.tar.gz

$ cd package-version

$ ./configure –prefix=”/usr” –sysconfdir=”/etc” –localstatedir=”/var”

$ make all

$ make install DESTDIR=”`pwd`-i686″

$ cd ..

$ createpet package-version-i686

or if you want a menu entry, then

$ createpet -m package-version-i686

Thats all, createpet will ask you some question. and finally your pet package will be ready with the name I also posted this script in puppylinux forum and people started to download. I’m waiting for someone to suggest something about the script.

You can also try this script and suggest me some improvements.