[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: perl script run by inetd ??



"Jerry Yu Z." <gs01zyu@panther.Gsu.EDU> writes:

> The script can be run at command line without any problem. Any clue?

As other people have said, you need a $|=1; at the top of your script.

> Actually, if I put /bin/cat as one of the inetd service, it will terminate
> the connection with something like "(none) --help".  When you type cat at
> comand line, it will repeats anyline you input. This really confused me. I
> thought server script run by inetd should read/write to STDIN/STDOUT.

>From the inetd manpage:

     The server program arguments should be just as arguments normally are,
     starting with argv[0], which is the name of the program.  If the service
     is provided internally, the word ``internal'' should take the place of
     this entry.

Many programs do not react well to being invoked with 0 arguments
(that is, with not even argv[0] set).  When you type "cat" at the
command line you do in fact invoke cat passing in the word "cat" as
the 0th argument.  When you just have a line that says:

9110  stream tcp nowait nobody /bin/cat

you invoke cat with 0 arguments, and it chokes.  Try instead:

9110  stream tcp nowait nobody /bin/cat cat

The behavior of programs in general without argv[0] set is interesting 
- for example, bash and tcsh segfault, perl thinks that part of the
environment is the name of the perl script one is trying to launch,
and cat gives this odd help message.  Echo works just fine.  Each
program to its own, I guess.


Reply to: