Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cgi script not invoked by javascript

Posted on 2013-06-15
17
Medium Priority
?
589 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 30

Expert Comment

by:Randy Downs
ID: 39250557
Are you seeing errors or just a blank page?
0
 

Author Comment

by:ddantes
ID: 39250582
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 84

Accepted Solution

by:
Dave Baldwin earned 1200 total points
ID: 39250587
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:ddantes
ID: 39250590
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 30

Expert Comment

by:Randy Downs
ID: 39250611
404 means the page doesn't exist
0
 

Author Comment

by:ddantes
ID: 39250624
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 30

Assisted Solution

by:Randy Downs
Randy Downs earned 800 total points
ID: 39250635
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 84

Expert Comment

by:Dave Baldwin
ID: 39250642
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
 

Author Comment

by:ddantes
ID: 39250675
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 84

Expert Comment

by:Dave Baldwin
ID: 39250693
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
ID: 39250698
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 84

Expert Comment

by:Dave Baldwin
ID: 39250798
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
ID: 39250813
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 84

Expert Comment

by:Dave Baldwin
ID: 39250874
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
ID: 39250938
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 84

Expert Comment

by:Dave Baldwin
ID: 39250974
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
ID: 39251544
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

971 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