Solved

cgi script not invoked by javascript

Posted on 2013-06-15
17
563 Views
Last Modified: 2013-12-25
I'm revising an online reservation system, which formerly  had the following javascript:

<script language="Javascript" type="text/Javascript">if(!parent.frames['MainFrame']){parent.location.href='/cgi-bin/rsv50load.pl?0001/ab0001.html';}</script>

In the new system, there are no frames, and the name of the page to load is different. However, the following code doesn't invoke the cgi script:
 
<script language="javascript" type="text/javascript">window.location.href='/cgi-bin/rsv50load.pl?rezeasy-ab.html';}</script>

Please advise.
0
Comment
Question by:ddantes
  • 8
  • 6
  • 3
17 Comments
 
LVL 29

Expert Comment

by:Randy Downs
Comment Utility
Are you seeing errors or just a blank page?
0
 

Author Comment

by:ddantes
Comment Utility
Thank you for your comment.  Not seeing an error.  The page -- booking_data.html -- loads, which says "please wait..." and nothing further happens.  The cgi script is supposed to transfer the visitor to our secure server and load a form.   If I try this with WampServer,  the Apache access log should have shown something like:

"POST /cgi-bin/rsv50std.cgi HTTP/1.1" 200 1691

but it doesn't show that.
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 300 total points
Comment Utility
First, the '}' at the end causes a syntax error and it won't execute because of that.  As soon as I removed that, it worked.  Remove that and see what's next.
0
 

Author Comment

by:ddantes
Comment Utility
That made a difference.  I get an error 404 now.  On WampServer, there is no cgi error, and the access log shows:
GET /cgi-bin/rsv50load.pl?rezeasy-ab.html
0
 
LVL 29

Expert Comment

by:Randy Downs
Comment Utility
404 means the page doesn't exist
0
 

Author Comment

by:ddantes
Comment Utility
I think, due to Dave's comment @ 1055, the initial syntax problem is fixed.  The 404 error has also been resolved by correcting a path error in a pl file.

Now there is a message:
Cannot open file: /srv/m/maui2/mtw/RezEasy/loadrsv.txt.
I think I should open another question relating to the loadsrv.txt issue.
However, the Apache access log still doesn't show POST /cgi-bin/rsv50std.cgi, and I would like to settle that.
0
 
LVL 29

Assisted Solution

by:Randy Downs
Randy Downs earned 200 total points
Comment Utility
You might get a better idea of what's happening with jsfiddle

http://www.youtube.com/watch?v=uFIyPWMfl-0

http://stackoverflow.com/questions/5655058/inspecting-javascript-on-jsfiddle-net-in-google-chrome

In the Developer Tools, under the Script tab if you select fiddle.jshell.net from the dropdown, around line 20-30 (depending on how much CSS you have) you will see a <script> tag that contains the code from the Javascript fiddle window. You can set your breakpoints here.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Loading a page thru "window.location.href" will Never show POST, always GET.
GET /cgi-bin/rsv50load.pl?rezeasy-ab.html  is the correct entry.  Only a <form> with 'post' or an AJAX using 'post' will ever show POST in the logs.

Is "/srv/m/maui2/mtw/RezEasy/loadrsv.txt" under the web root?  If not, then your CGI program may not have permission to access it.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ddantes
Comment Utility
Thank you.  Yes, the loadrsv.txt file is under the web root.

Regarding window.location never showing POST,  is that also true for parent.location?  Because, with the previous javascript -- and that function -- POST was in the logs.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
I'll say it again... Only a <form> with 'post' or an AJAX using 'post' can do an HTTP POST.  You can also create an HTTP POST with Perl and it's possible that that was what you saw.  But all links to another page with <a href""... or window.location are GET's.  You can not make them be POST's.

So it is really "C:/wamp/www/srv/m/maui2/mtw/RezEasy/loadrsv.txt"?
0
 

Author Comment

by:ddantes
Comment Utility
OK, the POST must have been accomplished through rsv50load.pl.

The local web root is V:\Program Files\Web Publish\Maui Site 1\RezEasy\loadrsv.txt.
(I'm aware of your admonition about empty spaces in these paths).

On the remote server, the path is:
srv/m/maui2/mtw/RezEasy/loadrsv.txt

I'll wait for your reply before closing this question, but I think I should award points for correcting my "}" syntax error, which addressed this question.

The loadrsv.txt issue should probably be posted as a separate question.  This program I'm trying to adapt is difficult for me to comprehend.  Pages are loaded by rsv50load.pl, which refers to rsv50conf.pl to determine base URL and pathways, and the cgi script is rsv50std.cgi.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
If 'V:\' is a mapped drive and 'loadrsv.txt' is actually on that remote drive, then you probably don't have permission to use it, particularly to write to it.  The 'rsv50...' programs will load but they will execute locally and may not have permission to access the remote drive.  They will still be running under the Apache user which doesn't want you to access non-local drives even if they are 'mapped'.

In general, web servers are 'sandboxed' to prevent you from doing things like accessing files on remote systems that are not available thru a web server.  Running it on a mapped drive is an attempt to straddle the line that doesn't always work.
0
 

Author Comment

by:ddantes
Comment Utility
Very well.  I copied my web files to the C:\ root directory, and changed httpd.conf references from V:\Program Files (etc.) to C:\Maui Site 1 (etc.).   I still get:
Cannot open file: /srv/m/maui2/mtw/RezEasy/loadrsv.txt
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
For what it's worth, here's the directory structure of my WAMP installation on C:.  Everything that is web accessible is in the 'www' directory or it's subdirectories.

WAMP directory structure
0
 

Author Comment

by:ddantes
Comment Utility
I'm glad to have that example.  My file system was organized before I ever heard of WampServer.  Being a creature of habit, I've got some resistance to altering its structure to accommodate WampServer.  At the same time, I'd like that application to be effective.

I'll award points now, and may post a question focused on the loadrsv.txt issue.

Thanks to both experts!
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Thanks for the points.  Maybe "/srv/m/maui2/mtw/RezEasy/loadrsv.txt" is hard-coded in one of the CGI files such that it doesn't look for it where it really is anymore.
0
 

Author Comment

by:ddantes
Comment Utility
I think you're right.  I may post a new question, and if so, I'll attach the relevant files.  Thanks again.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Getting AngularJS to work on jsfiddle 7 35
populate dynamic drop down from a csv 3 34
jqplot Pie Chart 2 11
onOpen 14 35
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now