• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

Why is the browser prompting to download my cgi file?

I have created a main html page that has a image link on it.  When I click on the image, it is supposed to take me to my login.cgi file which is a very basic login form using cookies.  However, when I click on the image, the browser actually shows a pop up window and asks me if I want to open, save or cancel the login.cgi file.  I have confirmed that my cgi file is in the cgi-bin folder and the permissions are set to 755.  I have also confirmed that the path is correct to my login.cgi file.  

Does anyone know why it is doing this?
0
deeayrian
Asked:
deeayrian
  • 4
  • 4
  • 2
  • +1
1 Solution
 
aboo_sCommented:
Are you using php asp.. never minds you have to set your pc to be a server hosting php or asp
after that you have to run your site through your local host.

You see when you turn the pc into a server you have to set a root directory for web so any requests on port 80 are directed to this directory, and right there your file should be stored and you can go there by pointing your browser to http://localhost. example : http://localhost/test/myloginscript.php
where my file is stored as such:  c:\www\test\loginscript.php where www is set as root directory.

There are a lot of ways to turn your pc into a server one of which is download and install xampp look it up in google
0
 
deeayrianAuthor Commented:
I am sorry, I forgot to specify that this is for a school assignment and my file is on a unix server.  Therefore the path specified is: https://crux.baker.edu/~dvelas01/cgi-bin/.....(the rest of my path)
I created another cgi file in the same exact directory as my login.cgi file and it worked just fine.  Both have 755 permissions and both were accessed from the same main html file (I just changed the name in the path to test it).
0
 
aboo_sCommented:
I see, could you try renaming your first cgi file that worked with some backup name and then rename this one that is not working with the frist one's name, so we can see if then it works?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
deeayrianAuthor Commented:
good idea.  But it didn't work.  
I also renamed the non-working file to login1.cgi and changed the path to open login1.cgi and it didn't work.  
I am using pico to manage the document so I don't know how to paste the code into here from there.
Any other ideas?
0
 
aboo_sCommented:
What I think you need to do is download files to your pc check file names check code, pate anything you like from here to there then upload them to the server and set permissions and then try again.
 
Now from admin point of view all cgi files in your account could be set to execute or your admin could have allowed only one specific filename to be excuted.

Could you paste your code for the login script here so I can more understand what is going on here!?
0
 
deeayrianAuthor Commented:
I really do not think this is an admin issue.  I have been doing assignments on this system for 6 weeks with no problems.  I was able to obtain my code for you.  It is posted below.  
#!/usr/bin/perl
#login.cgi - allows user to login to site using cookies
print "Content-type: txt/html\n\n";
use CGI qw(:standard -debug);
 
#prevent Perl from creating undeclared variables
use strict;
 
#declare variables
my $username;
 
#retrieve Name cookie
 
 
print <<htmlprint;
<HTML>
<title>American Idol Voting Contest</title>
<style type="text/css">
body {background-color: black}
td {font: arial, white}
h1 {font: arial, white}
</style>
<body>
<h1><center>Type your name below and hit submit to enter our website</center><h1>
<FORM ACTION='https://crux.baker.edu/~dvelas01/cgi-bin/finalproject/votes.cgi' METHOD=POST>
<table>
<tr><td>Full Name:</td><td><input type=text Name=Name SIZE=30 
VALUE='$username'</td></tr>
<br><br>
<tr><td><input type=submit Value=Enter Site></td></tr>
</body>
</table>
</FORM>
htmlprint

Open in new window

0
 
aboo_sCommented:
one other I can also think of is to check the file encoding.
Meaning try and paste the code into new notepad doc, then save as, make sure to choose all files and then ANSI and once done with it try uploading it and then set permission and try to run.

Another thing I hope you are trying to execute it from your pc using IE for example and not from the server.
0
 
Adam314Commented:
The content type should be "text/html", not "txt/html".  Also, you should be using the CGI module to send your header - you do not have a property formatted header the way you have it.

#!/usr/bin/perl
#login.cgi - allows user to login to site using cookies
use CGI qw(:standard -debug);
print header();  #Default content type is text/html
use strict;
...

Open in new window

0
 
deeayrianAuthor Commented:
The missing e in the word text is what was causing the problems.  Thank you very much.  As far as the header goes, the way I have it is not a problem.  It is the way we are taught to do it from our book and it works fine the way it is.  Thank you very much for catching the "e".  I looked over the code dozens of times but these tired eyes needed a second set.  
0
 
TintinCommented:
Sounds like your book is not a very good reference.  What's the name of it?
0
 
Adam314Commented:
I agree with Tintin - the book is teaching you to send an incorrect header.  Most (all?) browsers will work with the incorrect header anyways, but still, you should be doing it correctly.

Each header is supposed to end with the sequence: character 13, character 10.  Then at the end of all headers, an additional character 13, character 10 sequence.

The header function from the CGI module handles this.  

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now