Solved

cgi script not invoked by javascript

Posted on 2013-06-15
17
573 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
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 83

Accepted Solution

by:
Dave Baldwin earned 300 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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 29

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 29

Assisted Solution

by:Randy Downs
Randy Downs earned 200 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 83

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 83

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 83

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 83

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 83

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

773 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