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.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

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

    ... and, if there is any possibility of UDP packets coming in a “surge,” consider noting the time-of-day when the last packet was responded-to, so as to ignore subsequent packets that arrive too soon thereafter.