1

I am new to Perl and I just copied the Cleb answer (https://stackoverflow.com/a/28992992/5553963) (and also made the ajax.pl executable) but it doesn't work and it gives this error:

XML Parsing Error: not well-formed
Location: file:///home/workspace/snmp-agent/query_ui/ajax.pl
Line Number 1, Column 2:

When I run the ajax.pl there is no error but when I get the query via Ajax I faced above error and as you can see from Cleb answer the first line is: "#!/usr/bin/perl".

Can someone please give me a hint how to solve this?

1 Answer 1

3

CGI programs need to be executed by a web server (which has to be properly configured to execute CGI programs).

You are opening the file directly in a browser from the filesystem (we can tell because the Location is a file: scheme URL) and it is trying to parse it as XML (possibly you have associated pl files with the XML mime type in your OS somehow). Since it isn't XML, it fails.

Pick a web server, install it, and consult its manual on how to configure it to run CGI programs.

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

4 Comments

Thank you. As I said I am new to Perl, can you please introduce a server that I can install fast and with minimal config?
@AVarf For running a CGI script as a subprocess, CGI::PSGI together with plackup would be a good start IMO.
@AVarf — Apache HTTPD, Nginx, or Lighttpd
Just an update: I tried Lighttpd and Apache 2 both could ran the perl script but I couldn't send or receive messages (in Json format) so I just dropped it and used Flask and python could easily get the job done.

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.