ps :- I have read;
http://java.sun.com/docs/books/tutorial/essential/io/overview.html
caleb

Signature
There is no spoon
> What I am having trouble working out is which object I should create to
> call the man command and then return output to the user who issued the
> command.
Use java.lang.Runtime.exec or java.lang.ProcessBuilder to run another
program (/usr/bin/man in this case).
However, you should be *extremely* careful when doing this sort of
thing. I don't know the details of the command. However, I do know you
can, from the command line, change the path the program looks for files.
So potentially it a malicious IRC user could read other files on your
system. Also any programming error in man, for instance buffer
overflows, can now become security issues.
A better approach is to read the man files yourself. The are probably
gzipped and in the peculiar man format. Even then you need to be
careful. A malicious user may, for instance use ../ in keyword names.
Normalise the File object, and check it is still in the correct place.
UNIX will stop reading filenames at a NUL character, so checking them
becomes even more error-prone.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
caleb - 02 Jan 2006 13:59 GMT
> Use java.lang.Runtime.exec or java.lang.ProcessBuilder to run another
> program (/usr/bin/man in this case).
Hi Tom,
Thankyou for the advice. I have had a look at the java.lang.*
pages and am gratefull I have a direction to go in. I understand IRC is
not a safe place, I plan in running the bot in a jail on a machine in a
DMZ. I do not know much about jails' but am learning as I go.
My motivation for adding commands to run programs such as 'man' is that
IRC is a hostile environment. I have found that simple questions' can
illicit insults and flaming, being called an idiot is common. If someone
comes to a channel asking for *nix help and is a windows' user, the bot
can provide help and introduce the user to man pages(yes, I know they
are online).
I plan on adding channel management features and other bells' and
whistles. I am still learning as I go, it is alot of trial and error,
but it's *FUN*.
Thanks again,
caleb

Signature
There is no spoon.
Chris Smith - 04 Jan 2006 06:36 GMT
> Thankyou for the advice. I have had a look at the java.lang.*
> pages and am gratefull I have a direction to go in. I understand IRC is
> not a safe place, I plan in running the bot in a jail on a machine in a
> DMZ. I do not know much about jails' but am learning as I go.
External security is no excuse for writing insecure software. It would
be considerably better if you parse the user's command yourself, check
to be sure it doesn't contain any command line options or excessively
long Strings, and then build your own man command. You probably also
want to set your TERM variable to something safe that will prevent
escape sequences.
I'm not sure I agree with Thomas's suggestion to read the man page
yourself. Re-implementing nroff in Java doesn't sound like fun.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Chris Uppal - 04 Jan 2006 11:29 GMT
> I'm not sure I agree with Thomas's suggestion to read the man page
> yourself. Re-implementing nroff in Java doesn't sound like fun.
You have an oddly restrictive notion of "fun" ;-)
-- chris
Thomas Hawtin - 04 Jan 2006 18:18 GMT
> I'm not sure I agree with Thomas's suggestion to read the man page
> yourself. Re-implementing nroff in Java doesn't sound like fun.
Isn't there an nroff reader for Java?
No? Okay, run all the man pages through man2xyz, for some sensible xyz.
Bung the results in a database and Bob is your mother's brother.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/