tags:

views:

21

answers:

0

I am invoking a script via xinetd with the following service definition:

service gpsservice
{
    socket_type     = dgram
    protocol        = udp
    wait            = yes
    user            = root
    server          = path/to/my_php_script.php
    log_on_sucess   = HOST PID USERID
    disable         = no
}

which successfully launches the script, but I have no access to the message being sent over the UDP connection. I have tried the following approaches, just to see if anything but the script name is being passed in:

#!/usr/bin/php
<?php
        $text = implode(',', $argv);
        $f = fopen('/home/udp_test/text.txt', 'w');
        fwrite($f, "$text\r");
        fclose($f);
?>            


#!/usr/bin/php
<?php
        $handle = fopen("php://stdin","r");
        $text = fgets($handle);
        fclose($handle);

        $f = fopen('/home/udp_test/text.txt', 'w');
        fwrite($f, "$text\r");
        fclose($f);
?>

#!/usr/bin/php
<?php
        $text = implode(',', $_SERVER['argv']);
        $f = fopen('/home/udp_test/text.txt', 'w');
        fwrite($f, "$text\r");
        fclose($f);
?>            

To test these configurations, I use the following python script:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto('test', ('localhost', 9999))

But no matter what, I can't get access to the message 'test' within the PHP script. Is there something that I am missing?