in reply to Execute a Perl script in a browser

NEW RANTING:

1. have a link in the browser webpage that points to a pl file.
2. asociate your pl extension with a program you will write (and set the "always run with this program" so it doesnt pop up anymore)
3. clicking on this link creates a detached running of your program, with the pl as parameter (the same way a .doc file opens word)
4. the program runs perl, output into a temporal file with html extension, then runs firefox again with that page... which should open in a new tab/window

Ok, you will need to make a cmd program, then use bat2exe to make it an exe...

OLD RANTING:

Although in the past you could run arbitrary code in Firefox without a plug-in... it was deemed unsave and has been removed. There are some plug-ins that do that for you, but I can not find any at the moment. (and the output was passed as pure text, not re-rendered as html, so you still needed some jquery magic with a refresh to reload that as html)

If you still want to pursue this (without writing a webserver): Flash allows running arbitrary code, but support of it is iffy (and once you know what you can do with it, you never want flash active again when browsing other peoples webpages ;) ). Execute your perl output to a file, and load the result into your page.

And there this

https://en.wikipedia.org/wiki/TiddlyWiki

You can modify the plug-in to run your code, but you will need to modify the java code for it. As of now, it only read/saves.

disclaimer: THIS OPENS BACKDOORS INTO YOUR MACHINE THAT ANYMONE CAN USE!

So the best thing you can do:

Create a CMD/BAT script that you click yourself. And it does execute perl to a static page, then call firefox.exe and gives it that file. If firefox is already open, it will display it in a new tab.

Replies are listed 'Best First'.
Re^2: Execute a Perl script in a browser
by federico-perlmonks (Novice) on Apr 21, 2016 at 15:14 UTC

    I managed to run the script and open it in a new window, but it was not what I had in mind. You are probably right: the best solution, or at least the easiest, is to manually launch the program and then pass its output to firefox.

      Out of curiosity, since you aren't running a web server and all of this is local, why is there a requirement to display this in Firefox in the first place?

      If the base requirement is to have a GUI, then there are lots of ways to do that which do not involve the browser at all! I've made some pretty fancy GUI's with Tk, but there are other options. I'm just wondering if we may all be pounding away at the wrong "solution"? If the real question is "hey, I want a GUI", then the discussion goes into a whole different direction and probably should be a new thread.

      As another server option, one project that I'm working on (not done yet), is to get a Raspberry Pi 3 up and working with an Apache server for my "testing play box". I should be able to do this for less than $100 + brain sweat. This thing actually has enough horsepower to be a full Unix server the size of my palm.

      Update: see XY Problem

        You are right, I did not have a clear idea of what I wanted... The fact is that I had a .svg image as output of a little program and I found out that browsers can read svg; moreover I had just learned HTML and I wanted to "try it out" to see how it was like. So this idea to use firefox stuck in my mind and I could not think of anything else.

        However, it was just a for-fun-program, so I do not care if it is not perfect. Now I think the best solution would be to run a web server, but, actually, it does not worth. Of course I care of my program, but I am satisfied with having to run it manually and open its output in firefox.

        I will try not to fall anymore in the XY Problem.