Creating a server side telnet application / program


I’ve looked all over the web with no success on this. What I want to do is enable ssh/telnet on my OS/X system and build a server side application.

For instance, if someone used ssh or telnet to connect to my os/x system it would display a menu, or other program that I have written.

In short, I need to write a program that once someone connects via ssh/telnet the application will run and display a message for starters. I have no clue as how to set up the default landing folder, how to tell os/x that once someone logs in to run a particular application, nor information related to developing an application that will run over a telnet/ssh session.

Any suggestions are greatly appreciated.