LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-20-2002, 02:08 AM   #1
Rex_chaos
Member
 
Registered: Aug 2001
Location: GD, GZ, China
Posts: 240

Rep: Reputation: 30
Please check this program(perl) for me!


I don't know what's wrong. Thanks in advance.

#!/usr/bin/perl -w
use CGI qw(:all);
use strict;
my $name;
my $passwd;
my $cryptpasswd;
my $name=param('name');
my $passwd=param('passwd');
chomp $name;
chomp $passwd;

if (my $name eq "")
{ print "Please input your name!\n"; exit;}

if (my $passwd eq "")
{ print "Please input password!\n"; exit;}

my $cryptpasswd=crypt($passwd,"ss");
open (PASSWD,"/var/www/cgi-bin/shadow")||die "Fail to open file :$\n";
$shadow=;
close(PASSWD);
@shadow=split(/:/,$shadow);
print "$name\n";
print "$cryptpasswd\n";
print "$shadow[0]\n";
print "$shadow[1]\n";
if ((my $name eq $user) && (my $cryptpasswd eq $passwdshadow)) { print "Thanks!\n"; exit;}
else { print "Wrong input£¡\n"; exit;}
 
Old 04-25-2002, 04:21 PM   #2
ph34r3d
Member
 
Registered: Apr 2002
Location: Tamaqua, Pa
Distribution: Slackware. Gentoo 1.4rc3, RH9, Mandrake 9.1, Debian, FreeBSD, OpenBSD, Fedra Core 3 x86_64
Posts: 71

Rep: Reputation: 15
I think it's looking for a module you don't have declared
 
Old 04-25-2002, 06:56 PM   #3
gene_gEnie
Member
 
Registered: Aug 2001
Location: London UK
Distribution: Redhat 7.2, soon to be LFS!
Posts: 42

Rep: Reputation: 15
you using lots of variables that you havent declared.
Also, your declaring variables twice with the use of the 'my' statement

I think you should declare all your vars up to with 'my'

You dont use 'my' every time you use the var there after.

Also, i think what your trying to do with:
$shadow=;

would be better written as

$shadow=<PASSWD>;

That should read the file into the $shadow variable.
The next next line will then 'split' the var into separate elements and stick these in the @shadow array.

Also, what is $passwdshadow in the line:
if ((my $name eq $user) && (my $cryptpasswd eq $passwdshadow)) { print "Thanks!\n"; exit;}


this is the only time you've used this var so $cryptpasswd will never be equal to $passwdshadow

hth

Martin
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a RAM check program? kpachopoulos Linux - General 2 11-06-2005 04:59 PM
perl: warning: Please check that your locale settings: Daredevil Linux - Software 1 05-12-2005 10:47 AM
How to check which libraries does a program use? sceadu Programming 7 12-27-2004 07:39 PM
Perl Script To Check Logs Crashed_Again Programming 0 11-13-2004 03:13 PM
how to check the return value of a program Sammy2ooo Linux - General 1 04-27-2004 02:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration