Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Running a perl script from a html page

by Ankit.11nov (Acolyte)
on Dec 10, 2009 at 08:53 UTC ( #812125=perlquestion: print w/ replies, xml ) Need Help??
Ankit.11nov has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I want to run a perl script from a html web page.
<html> <head> <title>Run your first Perl script</title> </head> <body> Click on <a href="D:\workspace\run.pl">this link</a> to run your first + Perl script. </body> </html>

But when I am clicking on the link it is downloading the file instead of running it.
Please suggest what can be done here.

Comment on Running a perl script from a html page
Download Code
Re: Running a perl script from a html page
by desemondo (Hermit) on Dec 10, 2009 at 09:14 UTC
    sounds like you need to tell your webserver that your script run.pl needs executable permissions. this varies a bit depending on your webserver...


    *nix
    IIS - (see step 3)
      Can you please help as to how to set this web server permissions.

        Did you read the links provided? You've not told us what webserver you are using (IIS, Apache or something else?). For Apache see Setting up Perl/CGI with Windows from the tutorials section. For IIS read the link above or check out the IIS documentation.

Re: Running a perl script from a html page
by Anonymous Monk on Dec 10, 2009 at 09:24 UTC
    D:\workspace\run.pl is not a URL, so a webserver would never try to execute it.
Re: Running a perl script from a html page
by Utilitarian (Vicar) on Dec 10, 2009 at 09:47 UTC
    The url you have supplied is local, and so will just pull the file off your D: drive. you need to
    • install a webserver, I'd suggest Apache, but that's cos I like it
    • Configure a CGI directory in your webserver
    • Copy your script to this directory
    • Edit your page so that the link points to the absolute HTTP path to your script
    the info above is readily available on-line, however your question indicates a lack of understanding of the HTTP and CGI protocols, you should do a bit of reading to familiarise yourself with these. That said learning by doing is also to be recommended ;)

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

      Everything Utilitarian says is true about what's needed to get a web server (Apache, which I concur is most excellent) running to server up Perl CGI code. However, if you want to get started very quickly and avoid any configuration, might I suggest XAMPP to give you a single EXE that you can run to give you web server, Perl, and ready-to-run WAMP (Windows/Apache/MySQL/Perl+PHP) stack.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://812125]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-09-22 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (182 votes), past polls