freebsdman – script to display ‘man’ pages from freebsd.org

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 “http://www.freebsd.org/cgi/man.cgi”, 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.

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

DESCRIPTION:
        -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

EXAMPLES:
        $ 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,

attachlicense

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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* 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 'mohan43u@gmail.com' -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.

attachlicense

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.

#!/bin/sh 
# generatemail.sh - 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:

	generatemail.sh [-t tolist] [-s subject] [-e encodetype] 
		[-h] ATTACH_FILE1 ATTACH_FILE2 ...
"
HELP="${USAGE}
OPTIONS:
	-t tolist	comma seperated e-mail addresses
				(Default: current userid).

	-s subject	Subject line (Default: 'test mail from generatemail.sh
				 script')

	-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.

Eg:
	$ generatemail.sh -t foo@bar.com -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.

	Thanks,
	ben.
	[CTRL-D]
	$

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

TO="${USER}"
SUBJECT="testmail from generatemail.sh script"
BOUNDARY="`date +'%G%m%d%H%M%S'`"
ENCODE_TYPE="x-uuencode"

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

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

header()
{
	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: generatemail.sh 0.1"
}
create_octet_part()
{
	BASENAME=`basename "${1}"`
	FILE="${1}"

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

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

# Main

BODY="`cat`"
header
echo
echo "--${BOUNDARY}"
create_text_part
echo
echo "${BODY}"
echo
for FILENAME
do
	echo "--${BOUNDARY}"
	create_octet_part "${FILENAME}"
done
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 package-version-i686.pet. 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.

http://www.murga-linux.com/puppy/viewtopic.php?t=38311

Thanks.