in reply to trigger perl script from remote php script.
Rather than TCP; use UDP.
In your perl program you only need this to receive the notification:
#! perl -slw use strict; use IO::Socket; socket( SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('udp') ) or die "s +ocket: $!"; bind( SOCKET, sockaddr_in( 54321, inet_aton( 'localhost' ) ) ) or die +$!; my $input; while( 1 ) { my $addr = recv( SOCKET, $input, 1024, 0 ) or die $!; my( $port, $ipbin ) = sockaddr_in( $addr ); printf "Got '%s' from ip:%s port:%d\n", $input, inet_ntoa($ipbin) +, $port; }
In your PHP program, you can use this to send the '1' or '2' when required.
The Perl script above will block at the recv until it receives the datagram from your PHP program.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: trigger perl script from remote php script.
by locked_user sundialsvc4 (Abbot) on Jan 03, 2015 at 13:33 UTC |