Operating System - HP-UX
1753326 Members
4936 Online
108792 Solutions
New Discussion юеВ

Re: How to create a man page for my own commands?

 
Rashid Ali
Frequent Advisor

How to create a man page for my own commands?

Anybody knows how to create a man page for my own commands?

Thanks,
7 REPLIES 7
linuxfan
Honored Contributor

Re: How to create a man page for my own commands?

Hi Zhang,

You could try the following procedure to create/modify your own man page:

1. cd /tmp
2. cp usr/man/man1.Z/attributes.1 attributes.1.Z
3. uncompress attributes.1.Z
4. chmod 777 attributes.1
5. vi attributes.1
(You can modify this file for your own command)
6. mv attributes.1 myman.1
(this will create a man for myman command)
If you prefer you could keep this in your home directory and include the path to your man page in $MANPATH variable

or if you want to place it system directories(like /usr/man/man1.Z)
7. compress myman.1
8. mv myman.1.Z myman.1
9. cp myman.1 /usr/man/man1.Z

-HTH
Ramesh
They think they know but don't. At least I know I don't know - Socrates
Rashid Ali
Frequent Advisor

Re: How to create a man page for my own commands?

After uncompression and I use vi, I found the contents sound mystic. I show some of them as below, which seems to be formatted using nroff,tbl,mm or col.

I was told there is a tool to convert HTML file into an ASCII and vise versa, how about this one? Is there such tool that can convert an ASCII text file into this formated file?

.\" $Header: attributes.1,v 74.2 95/05/10 21:26:47 ssa Exp $
.TA a
.TH attributes 1
.ds )H Hewlett-Packard Company
.ds ]W HP-UX Release 10.20: July 1996
.SH NAME
attributes \- describe an audio file
.SH SYNOPSIS
.CI /opt/audio/bin/attributes \0filename
.SH DESCRIPTION
...
Bill Thorsteinson
Honored Contributor

Re: How to create a man page for my own commands?

There are docbook converters for SGML and XML that
create man pages.

Man pages are written in roff so check the man pages
for formatting instructions. "man -k roff" should list the
variations on your server. Common variations are
groff, nroff, and troff.

The macro for formatting man pages is called 'an' so
"roff -man yourpage.1" will test format your page.

Congratulations for your interest in creating your own
man pages.
Rashid Ali
Frequent Advisor

Re: How to create a man page for my own commands?

No, it cannot work.
Only nroff is available. But when I run
"nroff -man mycmd.1", it just combine a few lines into one single line. It does not add in prefix such as .TA, .ds, .SH into my text file, why? I believe these prefixes are according to the syntax of nroff and they will affect the behavior of man page. Is there any faster/automatic way to do that instead of doing this manually one line by one line?

Ralph Grothe
Honored Contributor

Re: How to create a man page for my own commands?

Hi Zhang,

I may have a much easier solution.

As you mentioned the nroff macro stuff is very cryptic.

If you have a recent Perl version installed (i.e. 5.X, not the 4.X HP furnishes its servers with, when will they finally realize the need for a current Perl?) you could generate POD (or socalled Plain Old Documentation).
The POD tokens are very easy to learn (just a handfull) and when you say "perldoc mycmd.pod" it exatly formats it like a manpage (incl. higlighting etc.).
See "perldoc perlpod" for a reference and tutorial to POD.
If however you still insist on having a real manpage from your POD file, no problem for Perl.
There exists a converter pod2man (see its POD, "perldoc pod2man")

HTH
Ralph
Madness, thy name is system administration
Gregory Fruth
Esteemed Contributor

Re: How to create a man page for my own commands?

The nroff macros used in man pages are described
in man(5). Type "man 5 man" to view the
documentation.

Once you've written a manpage file (start by copying
one of the system man pages), you can view it with
"nroff -man filename | more".

Most pages also use low-level nroff commands
in addition to the man(5) macros, so you'll need
to understand them as well. I suppose you could
make the analogy that "nroff -man" is to plain nroff
as LaTeX is to TeX.

HTH
Rashid Ali
Frequent Advisor

Re: How to create a man page for my own commands?

It can work now but I encountered another problem as shown below, actually I want to show an example,
.C "$ /usr/local/bin/ren "netlog_*.*" "#2.netlog_#1"" But it won't produce my expected result which is $ /usr/local/bin/ren "netlog_*.*" "#2.netlog_#1", why?

Another question is I found in /usr/share/man/cat1.Z also got attributes.1 besides the one in /usr/share/man/man1.Z, why?
how about /usr/share/man/man1 ?