0

I am trying to make a Perl script with arguments that can be executable via a web page. Can someone help me with getting started with the apache and the configurations for that? I've tried for multiple hours but nothing seems to work. I'm using Apache 2.4.29

14
  • What steps did you try in the multiple hours? Commented Mar 21, 2021 at 20:36
  • Maybe this question helps stackoverflow.com/q/8994348/1741542 Commented Mar 21, 2021 at 20:37
  • So I am trying to make it so it go to "localhost/cgi-bin/first.pl" but I keep getting apache errors and right now it tells me 403 Forbidden Commented Mar 21, 2021 at 20:38
  • Searching for apache cgi 403 gives stackoverflow.com/q/32416046/1741542 Commented Mar 21, 2021 at 20:40
  • To narrow the reason for the 403 error, look into Apache's log files: /var/log/apache2/access.log and /var/log/apache2/error.log. Commented Mar 21, 2021 at 20:43

1 Answer 1

1

An option to solve this still using perl is creating a small TCP service running in localhost in the server where you can send your parameters, and then you just configure a reverse proxy in apache to that port.

Example:

use strict;
use warnings;
use IO::Socket;  
  
my $port = 9999;  

my $server_socket = IO::Socket::INET->new(
     LocalPort => $port,
     Listen    => SOMAXCONN,
     Proto     => 'tcp',
     Reuse     => 1)
     or die "Cannot open socket: $!";
         

print "Server listening on port $port\n";  
  
while ( my $client_socket = $server_socket->accept() ) {
    my $client_host = $client_socket->sockhost();
    run_your_stuff();
    $client_socket->close();
}

   
sub run_your_stuff{
    print "Executing something...\n";
    system("ping google.es");
    # system("perl your_oder_script.pl");
}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.