Server script without built-in sockets

Craig White craigwhite at azapple.com
Mon Oct 22 18:43:59 MST 2007


On Mon, 2007-10-22 at 18:21 -0700, Kurt Granroth wrote:
> Here's an esoteric question for those of you wanting a challenge.  How
> can I turn an arbitrary non-networked bash script into a server?
> 
> Okay, I'll head a followup question off at the pass... "why would I want
> to do something insane like turning a bash script into a network
> server?"  The answer is "because".  Really, there's no reason other than
> I want to :-P
> 
> Now netcat handily has the exact option that I need: -e.  With that, I
> could do something like:
> 
> while 1; do netcat -l -p 16789 -e myscript.sh; done
> 
> Alas, the netcat people are reasonable and security conscious folk so
> they prudently refuse to enable the -e option by default.  In fact, to
> get that functionality, you must recompile netcat with the
> -DGAPING_SECURITY_HOLE compile flag!  I love it :)
> 
> But that doesn't help me because the solution that *I* want would
> require only software that I can reasonably assume would already be on
> any Linux system (no compiling!).
> 
> I suppose I could write a couple line perl script to handle the incoming
> connections... but it seems sacrilegious for a shell script to require
> perl.  Plus, not all Linux systems have perl.
> 
> [x]inted would certainly fit the bill but using that requires root
> access so that's out.
> 
> Am I out of luck, here?  Or is there some commonly available utility out
> there that can open up a socket for me?
----
perhaps I am missing something but there is a package called 'expect'
which does essentially what you want.

Craig



More information about the PLUG-discuss mailing list