Ad Widget

Collapse

exterminal script my smsgw problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zvukarmiso
    Junior Member
    • May 2015
    • 15

    #1

    exterminal script my smsgw problem

    Hello

    I'm solving a problem with my own sms gateway. If I upload the php file to the var/www/html directory and run it. sms me pride ascript works.

    Code:
    HTTP/1.1 200 Ok Server: Ethernut 4.9.10.0 Content-Type: text/xml Content-Length: 290 Connection: close 1 1
    When I copy it to the directory /usr/lib/zabbix/alertscripts, it throws me an error

    Code:
    sh: 1: /usr/lib/zabbix/alertscripts/gwtp.php: not found
    appliance@zabbix:/usr/lib/zabbix/alertscripts$ ls -l
    Code:
    -rwxrwxrwx 1 zabbix zabbix 1100 Jun 22 15:05 gwtp.php

    Code:
    #!/usr/bin/php
    
    <?php
    
    $type = "SMS";
    $nmr = $_SERVER["argv"][1];
    $nmr1 = $_SERVER["argv"][2];
    $text = $_SERVER["argv"][3];
    
    $host = "192.168.35.252";
    $port = 80;
    $user = "admin";
    $pass = "password";
    
    $xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <soapenv:Header/>
    <soapenv:Body>
    <pos:QueueAdd>
    <Queue>GsmOut</Queue>
    <Gsm>
    <Cmd>".$type."</Cmd>
    <Nmr>".$nmr."</Nmr>
    <Text>".$text."</Text>
    </Gsm>
    </pos:QueueAdd>
    </soapenv:Body>
    </soapenv:Envelope>";
    
    $fp = @fsockopen($host, $port, $errno, $errstr, 30);
    if (!$fp) {
    echo "$host:$port: $errstr ($errno)\r\n";
    }
    else {
    fwrite($fp, "POST /service.xml HTTP/1.0\r\n");
    fwrite($fp, "User-Agent: MyPHPTest\r\n");
    fwrite($fp, sprintf("Host: %s\r\n", $host));
    fwrite($fp, sprintf("Authorization: Basic %s\r\n", base64_encode($user . ":" . $pass)));
    fwrite($fp, sprintf("Content-Length: %d\r\n\r\n", strlen($xml)));
    
    fwrite($fp, $xml);
    while (!feof($fp)) {
    echo fgets($fp, 128);
    }
    fclose($fp);
    }
    
    ?>
    Can you advise where I make a mistake? why can't i do it
    Last edited by zvukarmiso; 22-06-2021, 17:25.
Working...