Page 2 of 2

Posted: Wed Aug 12, 2009 8:54 pm
by mrd
Here is my perl script that I use to feed room temperature to with a cron job...

Example:
./zm_trigger_sock.pl 4 32F


root@system-z:~/bin/cron_scripts# cat zm_trigger_sock.pl
#!/usr/bin/perl -w

use strict;
use IO::Socket;

our $mid = $ARGV[0]||'1';
our $string = $ARGV[1]||'Test';
our $port = $ARGV[2]||'6802';

my $buffer = $mid . '|show||||' . $string;

my $sock = new IO::Socket::INET (
PeerAddr => 'localhost',
PeerPort => $port,
Proto => 'tcp',
);

die "Could not create socket: $!\n" unless $sock;

print $sock "$buffer";

close($sock);

exit 0;

Posted: Wed Aug 12, 2009 10:47 pm
by Normando
mrd wrote:I take it back.. My perl script is working... Not sure why the .php won't work though...
Tips:

1- Enable php errors in php.ini (restart apache)
2- Ensure you have sockets compiled in php
3- Put a few "echo xxx;" between lines
4- Look in /var/log/messages and httpd errors.log