1

i have created this BASH script called blah which does something simple like this (See below)

#./blah -x "bindas"
hello bindas

i would like to execute script using xinetd with dynamic variable, something similar to below example

#telnet localhost 809 "bindas"
hello bindas. 

i am not going to use it with telnet, actually some other application will try to communicate with this server on 809 port. How can i arrange my xinetd file to take arguments? i found server_args can take parameters but how about something like this, will this work?

# This file is being maintained by Puppet.
# DO NOT EDIT

service cont_blah
{
        port            = 809
        disable         = no
        socket_type     = stream
        protocol        = tcp
        wait            = no
        user            = root
        group           = root
        groups          = yes
        server          = /usr/local/bin/blah
        server_args     = -x $1
}
bindas
  • 13
  • 3

1 Answers1

2

No that won't work.

Input received over your TCP socket is not interpreted by xinetd so can't be passed as a commandline argument to your script. Your script will need to read whatever data is received as standard input e.g.

#!/bin/bash
read name
echo "Hello $name"
HBruijn
  • 72,524
  • 21
  • 127
  • 192