[LDAPsh-cvs] ldapsh ldapsh,1.18,1.19
Status: Beta
Brought to you by:
rcorvalan
From: <j-d...@us...> - 2003-07-27 06:56:39
|
Update of /cvsroot/ldapsh/ldapsh In directory sc8-pr-cvs1:/tmp/cvs-serv30799 Modified Files: ldapsh Log Message: 1) Fixed spelling in diagnostic messages. 2) Now using consistent punctuation for diagnostic messages. 3) splitdn($$) renamed _splitdn($$) and moved to "utility functions" section. 4) "version" command now outputs ldapsh's SourceForge web address. 5) Fixed _entriesExpander for "csv" command. Index: ldapsh =================================================================== RCS file: /cvsroot/ldapsh/ldapsh/ldapsh,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ldapsh 27 Jul 2003 06:30:55 -0000 1.18 --- ldapsh 27 Jul 2003 06:56:36 -0000 1.19 *************** *** 354,358 **** if ($Globals->{LDAPCONN}{VALUE}) { unless($Globals->{LDAPCONN}{VALUE}{net_ldap_socket}->connected()) { ! print STDERR "\nConnection lost. Trying to reconnect\n"; undef $Globals->{_EFFECTIVECONNPARAMS}{VALUE}{BINDDN}; return 0 unless connect(); --- 354,358 ---- if ($Globals->{LDAPCONN}{VALUE}) { unless($Globals->{LDAPCONN}{VALUE}{net_ldap_socket}->connected()) { ! print STDERR "\nConnection lost. Trying to reconnect.\n"; undef $Globals->{_EFFECTIVECONNPARAMS}{VALUE}{BINDDN}; return 0 unless connect(); *************** *** 439,443 **** push @Specs, $_; } elsif (ref ($_)) { ! print STDERR "The argument passed as a reference is unknown\n"; return undef; } else { --- 439,443 ---- push @Specs, $_; } elsif (ref ($_)) { ! print STDERR "The argument passed as a reference is unknown.\n"; return undef; } else { *************** *** 464,468 **** push(@entries, @$searchedEntries); } else { ! print STDERR "\nError while searching according to filter '$spec'\n"; } } --- 464,468 ---- push(@entries, @$searchedEntries); } else { ! print STDERR "\nError while searching according to filter '$spec'.\n"; } } *************** *** 492,500 **** return 1; } else { ! print STDERR "No help found\n"; return 0; } } ############################################################# --- 492,505 ---- return 1; } else { ! print STDERR "No help found.\n"; return 0; } } + sub _splitdn($$) { + return (undef, undef) unless defined $_[0]; + split(/\s*,\s*/, shift, shift); + } + ############################################################# *************** *** 718,722 **** B<Synopsis>: C<which 'E<lt>commandE<gt>'> ! A synonym for L<help|help>. =cut --- 723,727 ---- B<Synopsis>: C<which 'E<lt>commandE<gt>'> ! A synonym for L<help E<lt>commandE<gt>|help>. =cut *************** *** 776,780 **** } if (! $found) { ! print STDERR "No help found on '$cmd'\n\n"; } unlink $podfile; --- 781,785 ---- } if (! $found) { ! print STDERR "No help found on '$cmd'.\n"; } unlink $podfile; *************** *** 793,797 **** sub version() { ! printf STDERR "LDAP Shell (ldapsh) by Rafael Corvalan.\nCVS File ID: %s\nShell release: %s\n\n", '$Id$', $RELEASE; } --- 798,802 ---- sub version() { ! printf STDERR "LDAP Shell (ldapsh) by Rafael Corvalan.\nCVS File ID: %s\nShell release: %s\nhttp://ldapsh.sourceforge.net/\n", '$Id$', $RELEASE; } *************** *** 908,912 **** # We will read the password, we need some privacy... ! # If we have Gnu ReadLine, we use it with it's ShadowRedisplay feature # Otherwise, we will use Term::ReadKey if (_isGnuReadLine and defined($attribs->{shadow_redisplay})) { --- 913,917 ---- # We will read the password, we need some privacy... ! # If we have Gnu ReadLine, we use it with its ShadowRedisplay feature # Otherwise, we will use Term::ReadKey if (_isGnuReadLine and defined($attribs->{shadow_redisplay})) { *************** *** 932,936 **** ); } else { ! print STDERR "Warning: Binding as anonymous\n"; $result = $Globals->{LDAPCONN}{VALUE}->bind( anonymous => 1, --- 937,941 ---- ); } else { ! print STDERR "Warning: Binding anonymously.\n"; $result = $Globals->{LDAPCONN}{VALUE}->bind( anonymous => 1, *************** *** 1084,1092 **** - sub splitdn($$) { - return (undef, undef) unless defined $_[0]; - split(/\s*,\s*/, shift, shift); - } - =head3 rdn --- 1089,1092 ---- *************** *** 1099,1103 **** sub rdn($) { ! my ($rdn) = splitdn(shift, 2); return $rdn; } --- 1099,1103 ---- sub rdn($) { ! my ($rdn) = _splitdn(shift, 2); return $rdn; } *************** *** 1130,1134 **** my $BasePath = $Globals->{CWD}{VALUE}; while ($SubPath =~ s/(?:,|^)\s*\.\.\s*$//) { ! (undef, $BasePath) = splitdn($BasePath, 2); unless ($BasePath) { print STDERR "Cannot go up on the directory tree!\n"; --- 1130,1134 ---- my $BasePath = $Globals->{CWD}{VALUE}; while ($SubPath =~ s/(?:,|^)\s*\.\.\s*$//) { ! (undef, $BasePath) = _splitdn($BasePath, 2); unless ($BasePath) { print STDERR "Cannot go up on the directory tree!\n"; *************** *** 1165,1169 **** if (_isReallyLDAPError($result->code)) { if ($result->code == Net::LDAP::Constant::LDAP_NO_SUCH_OBJECT) { ! print STDERR "Cannot change BaseDN. No such subpath\n"; return 0; } else { --- 1165,1169 ---- if (_isReallyLDAPError($result->code)) { if ($result->code == Net::LDAP::Constant::LDAP_NO_SUCH_OBJECT) { ! print STDERR "Cannot change BaseDN. No such subpath.\n"; return 0; } else { *************** *** 1210,1214 **** if ($status) { unshift(@{$Globals->{_DIRSSTACK}{VALUE}}, $cwd); ! print STDERR "Old working directory: '$cwd'\n\n"; } return $status; --- 1210,1214 ---- if ($status) { unshift(@{$Globals->{_DIRSSTACK}{VALUE}}, $cwd); ! print STDERR "Old working directory: '$cwd'\n"; } return $status; *************** *** 1235,1242 **** my $status = setdn($nwd); if ($status) { ! print STDERR "New working directory: '$nwd'\n\n"; } } else { ! print STDERR "The directories stack is empty\n\n"; $status = 0; } --- 1235,1242 ---- my $status = setdn($nwd); if ($status) { ! print STDERR "New working directory: '$nwd'.\n"; } } else { ! print STDERR "The directory stack is empty.\n"; $status = 0; } *************** *** 1338,1343 **** if (defined($entries)) { my ($n1, $n2) = (scalar(@$entries), scalar(@{$Globals->{ENTRIES}{VALUE}})); ! print STDERR "$n1 entries found\n"; ! print STDERR "$n2 entries in \$ENTRIES\n" if ($n1 != $n2); } --- 1338,1343 ---- if (defined($entries)) { my ($n1, $n2) = (scalar(@$entries), scalar(@{$Globals->{ENTRIES}{VALUE}})); ! print STDERR "$n1 entries found.\n"; ! print STDERR "$n2 entries in \$ENTRIES.\n" if ($n1 != $n2); } *************** *** 1363,1368 **** if (defined($entries)) { my ($n1, $n2) = (scalar(@$entries), scalar(@{$Globals->{ENTRIES}{VALUE}})); ! print STDERR "$n1 entries found\n"; ! print STDERR "$n2 entries in \$ENTRIES\n" if ($n1 != $n2); } --- 1363,1368 ---- if (defined($entries)) { my ($n1, $n2) = (scalar(@$entries), scalar(@{$Globals->{ENTRIES}{VALUE}})); ! print STDERR "$n1 entries found.\n"; ! print STDERR "$n2 entries in \$ENTRIES.\n" if ($n1 != $n2); } *************** *** 1514,1518 **** sub csv { my $localArgs = {fs => ';', vs => '|', 'mv' => 1, 'dn' => 0}; ! my $entries = _entriesExpander [$localArgs, 'dn', 'fs=s', 'vs=s', 'mv!', 'dn!'], @_; return 0 unless defined $entries; --- 1514,1518 ---- sub csv { my $localArgs = {fs => ';', vs => '|', 'mv' => 1, 'dn' => 0}; ! my $entries = _entriesExpander [$localArgs, 'fs=s', 'vs=s', 'mv!', 'dn!'], @_; return 0 unless defined $entries; *************** *** 1560,1564 **** printf("%s\n", $localArgs->{'l'} ? $entry->dn : rdn($entry->dn)); } ! print STDERR "-----\n" . scalar(@$entries) . " entries found\n"; return 1; --- 1560,1564 ---- printf("%s\n", $localArgs->{'l'} ? $entry->dn : rdn($entry->dn)); } ! print STDERR "-----\n" . scalar(@$entries) . " entries found.\n"; return 1; *************** *** 1672,1676 **** printf STDERR (qq{\t>>> Replace attribute '%s' with values: %s\n}, $data->[0], $attributes); } elsif ($action eq 'delete') { ! printf STDERR (qq{\t>>> Deleted attribute '%s'\n}, $data->[0]); } else { printf STDERR (qq{\t>>> Don't know the action '%s'\n}, $action); --- 1672,1676 ---- printf STDERR (qq{\t>>> Replace attribute '%s' with values: %s\n}, $data->[0], $attributes); } elsif ($action eq 'delete') { ! printf STDERR (qq{\t>>> Delete attribute '%s'\n}, $data->[0]); } else { printf STDERR (qq{\t>>> Don't know the action '%s'\n}, $action); *************** *** 1681,1687 **** if ($nbchanges) { ! print STDERR '=' x 40 . "\n$nbchanges entries to commit\n"; } else { ! print STDERR "No entries to commit\n"; } } --- 1681,1687 ---- if ($nbchanges) { ! print STDERR '=' x 40 . "\n$nbchanges entries to commit.\n"; } else { ! print STDERR "No entries to commit.\n"; } } *************** *** 1751,1755 **** my ($from, $to) = @_; $from = undef if ($from eq "*"); ! my $localcopy = (scalar(splitdn($to,2)) == 1); #I.e $to is an RDN. my $entries = _entriesExpander undef, $from; if (scalar(@$entries) != 1 && $localcopy) { --- 1751,1755 ---- my ($from, $to) = @_; $from = undef if ($from eq "*"); ! my $localcopy = (scalar(_splitdn($to,2)) == 1); #I.e $to is an RDN. my $entries = _entriesExpander undef, $from; if (scalar(@$entries) != 1 && $localcopy) { *************** *** 1759,1764 **** foreach my $entry (@$entries) { ! my ($oldrdn, $oldpath) = splitdn($entry->dn, 2); ! my ($newrdn) = splitdn($to, 2); my ($old_rdn_attr, $old_rdn_attr_val) = split("=", $oldrdn, 2); my ($new_rdn_attr, $new_rdn_attr_val) = split("=", $newrdn, 2); --- 1759,1764 ---- foreach my $entry (@$entries) { ! my ($oldrdn, $oldpath) = _splitdn($entry->dn, 2); ! my ($newrdn) = _splitdn($to, 2); my ($old_rdn_attr, $old_rdn_attr_val) = split("=", $oldrdn, 2); my ($new_rdn_attr, $new_rdn_attr_val) = split("=", $newrdn, 2); *************** *** 1868,1872 **** ($entries, $regexp) = @_; } else { ! print STDERR "Usage error\n"; return undef; } --- 1868,1872 ---- ($entries, $regexp) = @_; } else { ! print STDERR "Usage error.\n"; return undef; } *************** *** 2040,2044 **** return $var->{VALUE}; } else { ! print STDERR "You have no rights to fetch this value\n"; return undef; } --- 2040,2044 ---- return $var->{VALUE}; } else { ! print STDERR "You have no rights to fetch this value.\n"; return undef; } *************** *** 2053,2057 **** return($var->{VALUE} = $value); } else { ! print STDERR "You have no rights to set this value\n"; return undef; } --- 2053,2057 ---- return($var->{VALUE} = $value); } else { ! print STDERR "You have no rights to set this value.\n"; return undef; } |