Files
ansible/roles/apache_php/templates/usr_local_bin_fcgi-client
2025-10-10 11:07:34 +00:00

47 lines
896 B
Perl

#!/usr/bin/perl
use strict;
use warnings;
use Pod::Usage;
use Getopt::Long;
use IO::Socket;
use IO::Socket::UNIX;
use lib '/usr/local/lib/nagios/plugins';
use FCGI::Client;
GetOptions(
'h|help' => \my $help,
) or pod2usage();
pod2usage() if $help;
pod2usage() if @ARGV < 2;
my ($fcgi_file, $uri, $query_string) = @ARGV;
my $sock = IO::Socket::UNIX->new(
Type => SOCK_STREAM(),
Peer => $fcgi_file
) or die $!;
my $client = FCGI::Client::Connection->new( sock => $sock );
my ( $stdout, $stderr ) = $client->request(
+{
REQUEST_METHOD => 'GET',
REQUEST_URI => $uri,
SCRIPT_FILENAME => "/a/b/c$uri",
SCRIPT_NAME => $uri,
QUERY_STRING => $query_string || '',
},
''
);
print STDERR $stderr if $stderr;
print $stdout;
__END__
=head1 NAME
fcgi-client -
=head1 SYNOPSIS
$ fcgi-client foo.fcgi URI [foo=bar&hoge=fuga]