Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl and HTML

Status
Not open for further replies.

Oddgeir

Programmer
Jul 10, 2000
6
NO
Hi<br><br>I wonder if anybody could, PLEASE, tell me how to trigger a perl script from a html page. I want to use a button so one can press. Then my script starts and generates some info into a new html page, and then I want the new page to open in my browser window. Can anybody help, please.<br><br>Oddgeir
 
Well, you can use an HTML form, if I understand your question correctly, such as this:<br><br><FONT FACE=monospace><br><br>&lt;form method=post action=<A HREF=" TARGET="_new"> have all of your input text fields now --&gt;<br><br>&lt;input type=submit value=Submit&gt;&lt;input type=reset value=Reset&gt;<br><br></font><br><br>When you click the submit button, it will call your script and do whatever you want with it. Also, change the method to either get or post, depending on what you have your parser in your cgi script set to parse.<br><br><br>Hope this helps.<br><br><br>-Vic
 
Thanks Vikter, but I dont think I explained myself good enough. I will give it a new try.<br><br>First of all, I'm in Linux. I have a perl program that generate a html file from some other files on my computer. I do now want to run this perl program from a html-file in my browser without any input at all (the program workes fine without input). I just want my &quot;main&quot; page to have a little string of tekst ot the top(which is easy to make) and then a button to push for my program to start. Then I want to open my newly generated html-file in my browser. I'm new to scripting (as you probably can tell) so if you could take me trough this &quot;slowly&quot; it would be nice.<br><br>Sincerly,<br>Oddgeir
 
<font color=#0000DD>First of all, I'm in Linux. I have a perl program that generate a html file from some other files on my computer. <br>I do now want to run this perl program from a html-file in my browser without any input at all (the program workes fine without input).</font><br><br>You're saying the script has no inputs, you just want it to run? <br><br><font color=#0000DD>&gt;I just want my &quot;main&quot; page to have a little string of tekst ot the top(which is easy to make) and then a button to push for my program to start.</font><br><br>On your main HTML page:<font color=#00DD00><br>&lt;form action=yourCGIscript.pl method=get&gt;<br>&lt;input type=submit name=mybutton value=&quot;press me!&quot;&gt;<br>&lt;/form&gt;</font><br><br>Now your script - part 1:<FONT FACE=monospace><br>#!/usr/bin/perl (or wherever your perl is located)<br># send the HTTP header<br>print &quot;Content-type:text/html \n\n&quot;;<br>print &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;page title.... etc&quot;;<br>print &quot;Your message at the top of the screen..&quot;;<br></font><br><br><font color=#0000DD>Then I want to open my newly generated html-file in my browser. I'm new to scripting (as you probably can tell) so if you could take me trough this &quot;slowly&quot; it would be nice.</font><br><br>And part 2...<FONT FACE=monospace><br>open (INF, &quot;yourFilesName&quot;) or die (&quot;file does not exist&quot;);<br>while (&lt;INF&gt;)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;print $_;<br>}<br>close (INF);<br><br>#repeat the above for each file, in whatever order required<br></font><br><br>That should do it, if I've understood what you need correctly.<br><br>Hope it helps either way!!<br>Loon
 
I get a message about internal server failure when I push the button....what is all that about? The catalog in the httpd.conf is right. <br><br>Oddgeir
 
What message are you getting in you Apache error log?&nbsp;&nbsp;This will tell you a *lot* about why the script is failing. <p> <br><a href=mailto: > </a><br><a href= > </a><br>--<br>
0 1 - Just my two bits
 
If you can user server side includes you could use the line:<br><br>&lt;!--#exec cgi=&quot;path/to/perl/script.pl&quot; --&gt; <br><br>Might work :) <p>fortytwo<br><a href=mailto:will@hellacool.co.uk>will@hellacool.co.uk</a><br><a href= test site</a><br>
 
another thought......<br>If your program runs from a command prompt and does it's job, but it will not run via a CGI call through a web browser, you may have a permissions problem.&nbsp;&nbsp;When you run the code from a command prompt, the program has all the permissions you have.&nbsp;&nbsp;However, when you ask the program to run via a web browser, you are no longer the user.&nbsp;&nbsp;The web browser daemon is the user.&nbsp;&nbsp;For security reasons, such daemons are usually segregated and restricted to their own little areas in file systems ( eg htdocs and cgi-bin).&nbsp;&nbsp;<br><br>Does the program(web daemon) try to read from or write to a file that the web daemon does not have sufficient permissions to use?????<br><br>happy hunting :^) <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top