Telnetable script on a port

Hi, I have a fairly simple bash script that utilizes 1 argument and runs and display the results of this:
unixCmd ${arg1}

I'd like to run this script on a machine=myserver and attach to port 1234.

When a user on another machine., runs
telnet myserver 1234

Then the user types:
InputItem1

I'd like the response over telnet to be the standard-out of
unixCmd InputItem1

and then the connection closes.

How do I run the script that attaches to a port, listens for input, and send std-out to that telnet connection?

What do you mean by "attach to port"? You want your script to accept incoming connections?

Usually you'd use something like netcat for that.

Remember, only root can listen for connections on ports less than 1024.

Yes, I want the script to accept incoming connections over telnet and take one line of input, process that input, display the script's standard-out over the telnet connection. I still don't see how netcat pipes items into my script AND then pipes back the results.

I really don't want root running this script for security reasons, hence why I chose port 1234 for my example.

nc -l -e /bin/cat -p 1234

This will cause netcat to run /bin/cat whenever something connects to it, feeding the sockets input into cat, and feeding cat's output back into the socket. Try telnetting to localhost port 9000 1234 and typing lines into it, it'll spit them back to you. ( but be sure to keep a way to kill nc handy as telnet won't know when to quit!).

It can as easily run a shell script as cat.