Jan 31, 2000, 12:18 PM
Post #1 of 2
I have written a script which calls a telnet session to allow users to change their RAS passwords via a web page. It works fine as long as a user never makes a mistake (fat chance of that!!!)....so I put in an if statement to handle problems if the user gets an access denied. This also works fine...the first time only. Once the user gets access denied once, however, it gives the error back to user no matter if the entries are correct. I can't figure out the problem. Here is a snippet of the code that creates the problem. It works fine if the user does everything right, gives the correct error if the user does something wrong, and then gives the error every time after that until I change the "eq" to "==" or vice versa and rerun the script with the change.....doesn't make any sense to me. Any suggestions would be appreciated.
problem with IF in Perl 32 script
Also, another weird thing is that I have had to do a getline then lastline to get the correct string back from the telnet session (which is also strange...it doesn't return the access denied until I do a getline, lastline, then another lastline).
my($t, $hostname, $username, $tmppasswd, $newpwd, $confnewpwd, $passwd, $numchars, $logfile, $outlog, $dumplog);
use Net::Telnet ();
$formdata = new CGI;
$hostname = "---.---.---.---"; #IP num $passwd = "\#\#$tmppasswd";
. (this section has form validation stuff
$t = new Net::Telnet (Input_log => $logfile, Output_log => $outlog, Option_log => $optlog);
#The following print lines for for debug only
print "<HTML><HEAD><TITLE>Test</TITLE><BODY>BEFORE IF:<BR>LINE1: $line1<BR>LINE2: $line2<BR>LINE3: $line3<BR></BODY></HTML>";
if ($line3 eq "Access denied")
print $formdata->header; #line100
print "<HTML><HEAD><TITLE>RAS Change Error</TITLE><BODY>".
"<CENTER><H1>You have entered a Username or Password ".
"that is not recognized by the RAS server</CENTER><BR><BR></H1>".
"<H2>The username you entered was: $username<BR><BR>".
"The password you entered was: $passwd<BR>".
" [ignore the \#\# in front of the password]".
#the following print lines is for debug only
print "<HTML><HEAD><TITLE>Test</TITLE><BODY>If bombed $line LINE2 $line2 LINE3 $line3 </BODY></HTML>";
print "<HTML><HEAD><TITLE>RAS Change Made Successfully".
"</TITLE><BODY><CENTER><H3>The change to your RAS ".
"account has been made successfully.".
} #end of if formValid
} #end of subroutine