Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-30-2009, 09:32 PM   PM User | #1
ACS - Nick
New Coder

 
Join Date: Jun 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
ACS - Nick is an unknown quantity at this point
More sockets help

Hi,
Im very new to perl so still learning.

My aim is to have a script which checks a server for a flag to change and when it finds the change fire off a script I have in php.
The server is on a phone switch so I query a chanel and it give a responce eg:

I say ch1 it then says

busy:
Code:
ch1, Y, 01:23, 4402, 01xxxxxxxxx
(which is the chanel, flag, call duration, extension which has siezed the chanel and the destination)

or free
Code:
ch1, N

So the script I have so far is:

Code:
#! /usr/bin/perl -w
use IO::Socket;
use strict;

my($remote_host, $remote_port, $response, $socket);

#Server details
$remote_host = "10.2.101.20";
$remote_port = 343;

print "IPO Checker\nConnecting\n";

$socket = IO::Socket::INET->new(PeerAddr => $remote_host,
                                PeerPort => $remote_port,
                                Proto    => "tcp",
                                Type     => SOCK_STREAM)
    or die "Couldn't connect to $remote_host:$remote_port : $@\n";

print "Checking:\n";

    print $socket "ch1";
    $response = <$socket>;
    print $response;

# and terminate the connection when we're done
print "Done!";
close($socket);
Ultimately I will loop the check etc but first I would like to get a single check working (baby steps here )
The above I have hacked around from various tutorials and the bit im struggling with is sending and recieving the responce from the server.
ACS - Nick is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:34 AM.


Advertisement
Log in to turn off these ads.