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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what's wrong with this CGI script?? (premature script header)

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
hey.
similar post to my one below (same error neway).
But I managed to get that script to work.
However I have no-idea what's wrong with this scipt?:
-----------------------------------------------------
#!c:\perl\bin\perl

use CGI qw:)standard);
$object = new CGI;
$username = $object -> param('user');
$password = $object -> param('pword');

chomp($username);
open (USERS, &quot;< c:/users.dat&quot;) || die;
@users = <USERS>;
close(USERS);
$size = $#users;

if ($username gt $users[$#users]) {
open (USERS, &quot;>> C:/users.dat&quot;) || die;
print USERS $username, &quot;#&quot;, $#users + 1, &quot;\n&quot;;
close(USERS);
}
else {
$x = 0;
until ($username le $users[$x]) {
$x++;
}

@half = (splice(@users, $x));
$username .= &quot;#&quot;; $username .= $size + 1; $username .= &quot;\n&quot;;
push (@users, $username);
push (@users, @half);
open (USERS, &quot;> c:/users.dat&quot;) || die;
print USERS @users;
close(USERS);
}

$val = int(rand(59));
chomp($password);
$len = (length($password));
$z = 0;
open (PASS, &quot;>> c:/passwords.dat&quot;) || die;
until ($z == $len) {
$letter = substr($password, $z, 1);
$letter2 = $val * (ord($letter));
$z++;
print PASS $letter2, &quot;#&quot;;
}
print PASS $val, &quot;\n&quot;;
close(PASS);

print header;
print &quot;
<html>
<body>
<center>
<font size = 20>username is $username <br> password is $pword&quot;</font>
</center>
</body>
</html>
&quot;;
---------------------------------------------
im not too familiar with the protocol differences between cgi and perl, but I have the &quot;print header&quot; before any HTML etc... Is it maybe the opening of the files? or the CGIobject?

any and all suggestions are welcome!!
thankyou all!
JoE
we are all of us living in the gutter.
But some of us are looking at the stars.
 
Hi,

I don't have perl installed yet on my windows XP, so I can't test the script. However, you might try changing the first line to:

#!c:\perl\bin\perl.exe -w Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
It tested ok once i fixed one little thing...:

<font size = 20>username is $username <br> password is $pword)&quot;(</font>

That quote shouldn't be there... ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top