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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic CGI.PM doesn't work

Status
Not open for further replies.

RPrinceton

Programmer
Jan 8, 2003
86
US
Hi All,
I have a menu bar that I developed using Webstyle4 by Xara. I want to use the same menu bar in pages I develop dynamically using CGI.PM. Below is the code.

<HTML>
<HEAD>
<META http-equiv="Content-Language" content="en-us">
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META name="GENERATOR" content="Microsoft FrontPage 4.0">
<META name="ProgId" content="FrontPage.Editor.Document">
</HEAD>
<BODY>
<TABLE border="1" width="100%">
<TR>
<TD width="100%">
<P align="center"><script src="xaramenu.js"></script><script Webstyle4 src="nevbartest.js"></script>
</TD>
</TR>
</TABLE>
</BODY>

This code works when presented with, for a lack of better term "non-CGI.PM" HTML.

I have mimicked this code in CGI.PM. However it does not work. I have no idea why this shouldn't work. I'm relatively a novice when it comes to CGI.PM. I'm thinking that perhaps it cannot locate the scripts. Another thing I don't know is, when do these scripts get executed? I am assuming it occurs sometime after the CGI.PM has completely built the page. What is the timing of all of this? I hope this makes sense. Any and all help will be greatly appreciated. Thx in advance.
Regards,
Randall Princeton

 
These menu bar scripts you created are javascript and therefore get executed by the web browser. What happens is your CGI.pm script runs to generate basically what you posted above. That is then sent to the user's web browser. The browser sees there is javascript in the page and runs those scripts to create the menu. So really, your menu scripts have nothing to do with CGI.pm. CGI.pm runs on the server to create an html web page, javascript runs on the web browser to add functionality to that web page.

If you can't get the menu to work when using CGI.pm, go to the page in your web browser and do 'View Source'. This will show you what the server has generated and sent to your web browser (again, it should look a lot like what you posted above). For more help, post your CGI.pm script as UnixJunky has said.

Another thing to note is that if your CGI script is generating correct HTML then the problem may be with the location of your CGI script. Usually CGI scripts are in a different directory (normally cgi-bin), so your links to your javascript menus as you have shown them aren't correct. The browser will be looking in that cgi directory for the scripts. You can try putting a "/" in from of the script names, telling the browser to look in the main directory of your web site for the scripts. So for example you'd have:
Code:
<P align="center"><script src="/xaramenu.js"></script><script Webstyle4 src="/nevbartest.js"></script>
It's good practice to do this anyway in case you ever have html pages in other directories that use the menu.

 
he's right y'know, script location, though it might be an idea to move your scripts into a subdirectory
--Paul

cigless ...
 
Hi UnixJunky,
Please find below my Perl script that contains CGI.PM that will not present the menu constructed by the javascript.

Script follows:
#!/usr/bin/perl -w
---------------------------------------------------------
# Name: DispSch
# Desc: Show Forum
# Pgmr: Randall Princeton/Excellence in Software
# Date: Jan 6, 2005
# ----------------------------------------------------------
use ScriptErrorLog;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Carp qw(warningsToBrowser);
use CGI qw:)standard);
use myVars;
$mvHTML = new CGI;
@tabHTML = "Content-Type: text/html\n\n";
@tabHTML = (@tabHTML,"<html>\n");
@tabHTML = (@tabHTML,"<head>\n");
@tabHTML = (@tabHTML,"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n");
@tabHTML = (@tabHTML,"<meta http-equiv=\"Content-Language\" content=\"en-us\">\n");
@tabHTML = (@tabHTML,"<meta name=\"GENERATOR\" content=\"Microsoft FrontPage 4.0\">\n");
@tabHTML = (@tabHTML,"<meta name=\"ProgId\" content=\"FrontPage.Editor.Document\">\n");
@tabHTML = (@tabHTML,"</head>\n");
@tabHTML = (@tabHTML,"<body>");
@tabHTML = (@tabHTML,"<table border=0 width=100%>");
@tabHTML = (@tabHTML,"<TR><TD width=100%>");
@tabHTML = (@tabHTML,"<p align=center><script src='xaramenu.js'</script><script Webstyle4 src='nevbartest.js'</script>");
@tabHTML = (@tabHTML,"</TR></TD>");
@tabHTML = (@tabHTML,"</table>");
@tabHTML = (@tabHTML,"</body>");
@tabHTML = (@tabHTML,"</html>\n");
RetSchHTML();
exit(0);

# ----------
sub RetSchHTML
{
print <<DYN;
@tabHTML
DYN
$mvHTML->end_html;
}

Please let me know if you need any more info.
Regards,
Randall Princeton
 
Randall,

did you look @ philote's post

--Paul

cigless ...
 
PaulTeg,
If you are referring to placing a slash before the script name...yes I have tried that along with other variations of the path e.g., /public_html/cgi-bin/xaramenu.js etc. I can also tell you that I have the scripts in two directories, public_html and public_html/cgi-bin. FYI directory public_html/cgi-bin is also where my Perl script resides. This is why it is puzzling to me why it doesn't work.
I am certainly open to any other ideas.
Kindest regards,
Randall Princeton
 
Randall,

I'm convinced it's about the location, I spent a good while sussing this out before myself

try just referring to the xaramenu.js in the public_html directory, but refer to it as
Code:
@tabHTML = (@tabHTML,"<p align=center><script src='[COLOR=red][URL unfurl="true"]http://www.yourdomain.com/[/URL][/color]xaramenu.js'</script><script Webstyle4 src='nevbartest.js'</script>");

On apache, unless you change the default permissions, you can't serve images, and perhaps scripts from the cgi-bin directory or below it.

HTH
--Paul


I had that written above and then I copped the typo
<script src='xaramenu.js'></script>

cigless ...
 
Hi PaulTeg and Philote,
I am including all the variations I have tried with regard to defining the path to the script, i.e., xaramenu.js. None of which worked. They are listed at the bottom of the mainline script as comments.

#!/usr/bin/perl -w
# ----------------------------------------------------------
# Name: DispSch
# Desc: This script displays the season schedule
# Pgmr: Randall Princeton/Excellence in Software
# Date: Jan 6, 2005
# ----------------------------------------------------------

use ScriptErrorLog;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Carp qw(warningsToBrowser);
use CGI qw:)standard);
use myVars;

$mvHTML = new CGI;
@tabHTML = "Content-Type: text/html\n\n";
@tabHTML = (@tabHTML,"<html>\n");
@tabHTML = (@tabHTML,"<head>\n");
@tabHTML = (@tabHTML,"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n");
@tabHTML = (@tabHTML,"<meta http-equiv=\"Content-Language\" content=\"en-us\">\n");
@tabHTML = (@tabHTML,"<meta name=\"GENERATOR\" content=\"Microsoft FrontPage 4.0\">\n");
@tabHTML = (@tabHTML,"<meta name=\"ProgId\" content=\"FrontPage.Editor.Document\">\n");
@tabHTML = (@tabHTML,"<script src='../xaramenu.js\'</script><script Webstyle4 src='nevbartest.js'</script>");
@tabHTML = (@tabHTML,"</head>\n");
@tabHTML = (@tabHTML,"<body text='#0000FF'>");
@tabHTML = (@tabHTML,"Text Here\n");
@tabHTML = (@tabHTML,"</body>");
@tabHTML = (@tabHTML,"</html>\n");
RetSchHTML();
exit(0);
#@tabHTML = (@tabHTML,"<script src='../xaramenu.js\'</script><script Webstyle4 src='nevbartest.js'</script>");
#@tabHTML = (@tabHTML,"<script src='/cgi-bin/xaramenu.js\'</script><script Webstyle4 src='nevbartest.js'</script>");
#@tabHTML = (@tabHTML,"<script src=' Webstyle4 src='nevbartest.js'</script>");
#@tabHTML = (@tabHTML,"<script src=' Webstyle4 src='nevbartest.js'</script>");
#@tabHTML = (@tabHTML,"<script src=' Webstyle4 src='nevbartest.js'</script>");
#@tabHTML = (@tabHTML,"<script src=' Webstyle4 src='nevbartest.js'</script>");
# ----------
sub RetSchHTML
{
print <<DYN;
@tabHTML
DYN
$mvHTML->end_html;
}

Is it a possibility that there may be some bad characters
causing the browser not to parse properly? Another thing I notice when I "view" the source in the browser, I see some whitespace. I wouldn't however think that would cause the browser to balk. This just seems to simple to me not to work. Please advise. Thx in advance.
Regards,
Randall Princeton
 
Code:
[COLOR=green]@tabHTML = (@tabHTML,"<script src='../xaramenu.js\'[/color][COLOR= red][b]>[/b][/color][COLOR=green]</script><script Webstyle4 src='nevbartest.js'</script>");[/color]

You need to close the script tag as highlighted
--Paul

cigless ...
 
Hi All,
The problem is solved! I want to thank everyone who replied. I am convinced I would not have solved this on my own. PaulTEG's solution is what worked, i.e., I had to include the "http" portion to the source path. What confuses me is that when the browser accesses the website, doesn't the URL place you at the public_html directory inherently? I have a few manuals on HTML and they gloss over the area of source path. Some of the manuals show the path as ../scriptname.js. Experience rules! Again I am extemely grateful to everyone.
Kindest regards,
Randall Princeton
 
RP,

Great you got that sorted, the 'http'??

It was a typo, it happens

--regards
A1

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top