MacOSX.com free perl script assoc.

To set it up for inetd, first put the script someplace publically-readable (but not writable) like /usr/local/bin or something.
Then we need to setup the reverse service. On other *nix, you would add a line to /etc/services, but this is Darwin/OS X, which uses NetInfo, so instead we must run
Code:
sudo niutil -create / /services/reverse
sudo niutil -createprop / /services/reverse port 9876
sudo niutil -createprop / /services/reverse protocol tcp
This creates an entry in NetInfo's services directory called reverse (change if you prefer it called something else); it has two properties: port (9876, again, change if you want a different port), and protocol (tcp).

Now we need to tell inetd about reverse:
  1. edit /etc/inetd.conf (with pico, vi, whichever you prefer)
  2. add the line
    Code:
    reverse stream  tcp     nowait  nobody  /usr/local/bin/reverse.pl reverse.pl
    then save it
  3. run
    Code:
    kill -1 `cat /var/run/inetd.pid`
Change the path and scriptname in step 2 if they are different. After this, you should be able to
Code:
$ telnet localhost 9876
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
this is the reverse server
revres esrever eht si siht
Connection closed by foreign host.
One thing to note is be sure you save the script with Unix-type linebreaks; the attachment wasn't.

For those curious, see man inetd for information on the line added to inetd.conf (note the user used is nobody which is a security feature as this particular server shouldn't need any serious access).
 
Thank you! It really is an internet super-server!

Cool, now you can run any perl script via inetd! I'll even try a C app.

Dricci: Look at the title of this thread. Create your own assoc. :D
 
Back
Top