Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: More sockets help
09-30-2009, 10:32 PM #1
- Join Date
- Jun 2009
- Thanked 0 Times in 0 Posts
More sockets help
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:
ch1it then says
ch1, Y, 01:23, 4402, 01xxxxxxxxx
So the script I have so far is:
#! /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);
The above I have hacked around from various tutorials and the bit im struggling with is sending and recieving the responce from the server.