Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

cgi script not invoked by javascript

Posted on 2013-06-15
17
Medium Priority
?
592 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
Industry Leaders: 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!

 

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

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.

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

581 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