0

Given that I have a local Perl script that prints "Hello" in a windows command prompt.

I want to make a Web Interface that when I click a button on an HTML page using Javascript or something, I'd be able to execute this local Perl Script. I have tried hosting the page on Localhost in an Xampp Apache server however this uses the Perl installed on Xampp.

Is there anyway to interact with local Perl from a Web User Interface? i.e. Running a perl script in the local shell from a Web UI.

5
  • This sounds like a potential security nightmare... Commented Jun 12, 2012 at 20:21
  • Would you be able to explain why? I am writing this to be completely offline. I would just want to use a Web UI to be the GUI for a Perl Script. Commented Jun 12, 2012 at 20:22
  • 2
    JavaScript is not designed to allow a server to push code to a browser that would result in an application on a user's system being executed. Imagine if you could execute fdisk. Commented Jun 12, 2012 at 20:22
  • 1
    In that case, you could use Dancer, Mojolicious, or Catalyst to set up a web app that runs off of localhost. Commented Jun 12, 2012 at 20:29
  • 1
    One approach is to get the user to cooperate in running a daemon that listens for a request on some port, and takes some action when so prompted. Seems like a hard sell at first, but it's far more common than you might suspect at first. Sure, nobody really wants to install Apache for you. But Yahoo and Skype have been pretty successful in getting you to install a daemon: Yahoo Messenger. It becomes your responsibility to assure that the daemon you're providing for someone to install is not riddled with security holes. That part is difficult. Commented Jun 12, 2012 at 20:40

2 Answers 2

3

I usually run a perl script that works as a primitive web server. Upon startup it prints a URL which can be used to access it.

This can be done with the following modules:

use HTTP::Daemon;
use HTTP::Status;
use HTTP::Response;

in about 60 lines of code.

Can't post my code, but here is a more elaborate sample (it uses fork, which is an improvement over what I have): http://www.perlmonks.org/?node_id=415908

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

Comments

0

Look into Node JS... it can call perl from the webpage, is very very simple to set up and get a localhost site going, and is free.

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.