Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

-e (existing file)

Status
Not open for further replies.

Zas

Programmer
Oct 4, 2002
211
0
0
US
Anyone see anything wrong with this?:

if (-e "$lccname/$lcpassl.txt") { sleep(1) } else { print "Invalid Charecter Name or Password!"; exit; }

When I log in, and the file exists, it is perfect. When any charecter is not typed in, it does:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, support@netfirms.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


My server sucks, so it doesn't show the errors right now. I will get to that later if its possible.

Anyways, anything wrong with the script?
 
i missed the defs of your 2 variables, a ; after sleep, a \n in print and a status in exit: exit(1);
i don't believe this code cause the error vox clamantis in deserto.
 
If you are accessing this through a web interface make sure you return a complete set of headers.

print "Content-type: text/html";

If applicable HTH,
 
put this as the 2cnd line in your script to get more useful errors in your browser:

use CGI::Carp qw/fatalsToBrowser/;

--jim
 
ok-
#!/usr/local/bin/perl
use CGI::Carp qw/fatalsToBrowser/;

I had the vars defined just didn't type them in.

$lcpassl = lc($INPUT{'passl'});
$lccname = lc($INPUT{'cname'});
if (-e "$lccname/$lcpassl.txt") { sleep(1); } else { print "Invalid Charecter Name or Password!\n"; exit(1); }

I wanted to exit the entire script for exit- does exit(1) just exit the "if"?

Also the use CGI::Carp qw(fatalsToBrowser); on the 2nd line, didn't show anything on the browser, it still returns "Internal Server Error ... ". That is exactly what netfirms wanted me to do though. Purhaps whats wrong with that, is it doesn't relate to my error?

I'll try having the
print "Content-type: text/html";
before everything else, too. Than that would make my cookies show up.
print "Set-Cookie: NAME=$cid\n";
would actually print Set-Cookie: Name=$cid" on the website. I cannot define the cookie until I open the script, and the files though.

Any suggestions?
By the way- Thanks for the help-
 
If when you put the line print "Content-type: text/html";
in to the script does it run. Just try it for debugging perposes. If so you problem is to do with the header that is setting the cookie and that is where you problem lies.

If it is the problem the I suggest using the CGI.pm module it comes standard with PERL.
 
Well everything is great, except yes, it does say "Set-Cookie: NAME=$cid" where I told it to print the cookie. The cookie I have works fine, I just donot want others to see it. Is there a special print, or anything where I can write things into the website, but not have them see it, if I have already written content-type:text/html?
 
exit() has to write an error message somewhere - usually in the server log. But if the program has already closed, how will it do this? This is a problem where ever you use perl on a server - you always get the standard error page!
Look in your servers error log to see if the exit has been reported - it probably has!
The only way to get a 'clean' exit, i.e. not visible on the browser, is to let the program finish naturally! Trying to force the program to exit will always produce this error.
 
The error you are getting is related to not supplying a complete set of headers from the CGI script to the browser. So you error really lies in the header that is setting the cookie I would suggest looking there for the bug. Again CGI.pm is simple to use for setting and retreiving cookies and It is bundled with PERL. If you need documentation on the module try PERL.com or cpan.org or activstate.com for further informations. You also can access on you local computer if you have perl installed there.

HTH-
 
Thanks for the help. I'm good now. My real error now, is when I print DAT "::$var"; etc.. with all the variables in there, it ALWAYS only prints the last variable into the file, and nothing else. I tryied saving them all into a @allvar, but than it wouldn't seperate. :( I'll post in another thread for this subject.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top