
October 13th, 2012, 12:19 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 1
Time spent in forums: 6 m 3 sec
Reputation Power: 0
|
|
|
Help, For the rndpass.pl
I want to have Usage:
rndpassword [-v] [-t <type>] [-n <length>]
Options:
-v version
-t set character type (default: num)
-n set length (default: 8 byte)
Types: (output sample)
alnum 0xaVbi3O2Lz8E69s # 0..9 a..z A..Z
num 12378654 # 0..9
Examples:
shell> rndpassword <CR>
Password: 01234567
shell>
shell> rndpassword -n 16 <CR>
Password: 0123456789012345
shell>
shell> rndpassword -t alnum -n 4 <CR>
Password: abcd
shell>
shell> rndpassword -v <CR>
Version: 0.1
Password: 01234567
shell>
shell> rndpassword -n 3 -v <CR>
Version: 0.1
Password: 012
shell>
shell> rndpassword -n 3 -v -n 4 <CR>
Version: 0.1
Password: 0123
shell>
but my code just doesnt work perfectlty Quote: #!/usr/bin/perl # password generator client (PROTOTYPE)
# Peter Walsh csci 265
use warnings "all";
use Getopt::Std;
use IO::Socket; $sock = new IO::Socket::INET (
PeerAddr => '192.168.18.21',
PeerPort => '7071',
Proto => 'tcp' );
die "Could not create socket: $!\n" unless $sock;
Getopt::Std::getopts 'v:t:n' => my $opt = {};
if( defined $opt->{n} and defined $opt->{t} )
{ printf STDERR "notice: -n and -t options are exclusive.\n";
exit 1; }
# length my $n = 8;
if (defined $opt->{v} || 'default')
{ print "version:0.1\n"; }
if( defined $opt->{n} )
{ print $sock "1:x&num:8\n" }
if (defined $opt->{t} ) {
print $sock "1:num:6\n"; }
while (1) { $pass = <$sock>;
chop $pass;
last if $pass eq "CLOSE";
print "$pass \n"; } |
Last edited by Hanxiang : October 13th, 2012 at 12:21 PM.
Reason: fix code
|