Sponsored Content
Top Forums Shell Programming and Scripting Unix Arithmatic operation issue , datatype issue Post 302166963 by thambi on Wednesday 13th of February 2008 06:35:31 AM
Old 02-13-2008
Reply..

As I already mentioned, it just contains the 7 digiti number in every row. Like these, this file has around 150000 . We just need to add all the rows..that's all

0000001
0000343
0000001
0001426
0000001
0000718
0000162
0000103
0000021
0000011
0000016
0000312
0000026
0000031
0000005
0000022
0000001
0000001
0011845
0003713
0000001
0000011
0000001
0000001
0000001
..,.,
........
.......
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX variable issue

Hi all, Something funny happen with this code: EXIST=`ssh batch@190.2.332.234 'if ; then echo 0; else echo 1 ; fi'` echo $EXIST Above code will display "1". The value of remotePath is /home/batch The value of fileName is sample.txt ========================================= ... (1 Reply)
Discussion started by: suigion
1 Replies

2. UNIX for Dummies Questions & Answers

ISSUE and ISSUE.NET files

In LINUX(CentOS, RedHat) is there a way to have the banner statement appear before the logon instead of after the logon? In UNIX and Windows the banner appears before a person actually logs on, what I'm seeing in LINUX is that it appears after the login(ftp, telnet, SSH). Thanks (0 Replies)
Discussion started by: ejjones
0 Replies

3. Shell Programming and Scripting

Issue with Sort in Unix

Hi All, I am trying to sort the below data using sort command. temp.dat H|S1-511091486889|27-Jul-2011 00:00:00 H|S1-511091486823|27-Jul-2011 00:00:00 H|S1-511091486757|27-Jul-2011 00:00:00 L|S1-511091486889|1 L|S1-511091486823|1 L|S1-511091486757|1 sort -t "|" -k2 -k1 temp.dat My... (5 Replies)
Discussion started by: deepaknbk
5 Replies

4. Shell Programming and Scripting

Need assistance with a file issue and a terminal issue

Hello everyone, I'm in need of some assistance. I'm currently enrolled in an introductory UNIX shell programming course and, well halfway through the semester, we are receiving our first actual assignment. I've somewhat realized now that I've fallen behind, and I'm working to get caught up, but for... (1 Reply)
Discussion started by: MrMagoo22
1 Replies

5. Windows & DOS: Issues & Discussions

UNIX AD idmap issue

Hi, I'm having a nightmare of a time with this one. I've recently taken over a sys admin role and shortly after I did, the print server failed. I've had to replace the hard disk. ---don't ask about backups....there hasn't been a sys admin in post for almost a year...... Anyway, the aim, to... (0 Replies)
Discussion started by: rudigarude
0 Replies

6. Shell Programming and Scripting

.profile issue with UNIX

Hi, There is a user in Solaris-10 zone, ora_big01. Its .profile is not getting executed due to some reason and I am not able to find that. root@trddpd-dwsq04:/# cat /etc/passwd | grep -i ora_big01 ora_big01:x:242349:220:Siebel for QA:/ccq/apps/siebel:/usr/bin/ksh root@trddpd-dwsq04:/# which ksh... (3 Replies)
Discussion started by: solaris_1977
3 Replies

7. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

8. UNIX for Advanced & Expert Users

UNIX Mount Issue

Hi, Not entirely sure if this is the right thread. Essentially, fdisk -l shows that /dev/sda is a drive (750 GB), with 1 partition at /dev/sda1 with system type "Linux". I'm pretty nooby at working with drives, but I'm pretty sure that the output of: mount /dev/sda1 /media/int Should not... (4 Replies)
Discussion started by: FreddoT
4 Replies

9. Shell Programming and Scripting

If Condition Issue in UNIX

Hi I am trying to do a "IF" Condition in UNIX where we compare EACH file size in a directory with a SIZE (Parameter passed) If Each File size EXCEEDS parameter passed SIZE then we manipulate the file. Somehow the IF condition do not work ?? (is this Variable decalration issue ??) ... (9 Replies)
Discussion started by: Pete.kriya
9 Replies

10. Shell Programming and Scripting

UNIX email issue

Hi all, I have tried to send an email with the below script. but i am not getting the subject of the email where it is present in the simply.txt. I am using HP UNIX server. I am not sure what mistake i made in the below unix command. any help would be appreciated. cat simply.txt ... (2 Replies)
Discussion started by: arun888
2 Replies
Net::LDAP::Examples(3)					User Contributed Perl Documentation				    Net::LDAP::Examples(3)

NAME
Net::LDAP::Examples - PERL LDAP by Example DESCRIPTION
The following examples are of course PERL code, found to work with the Net::LDAP modules. The intent of this document is to give the reader a cut and paste jump start to getting an LDAP application working. Below you will find snippets of code that should work as-is with only a small amount of work to correct any variable assignments and LDAP specifics, e.g. Distinguished Name Syntax, related to the user's own implementation. The Standard Operating Proceedure that is followed here is: 1 Package - use Net::LDAP 2 Initialization - new 3 Binding - bind 4 Operation - add modify moddn search 4.1 Processing - displaying data from a search 5 Error - displaying error information 6 Unbinding - unbind Look to each of these for a snippet of code to meet your needs. What is not covered in these examples at this time: abandon and compare methods callback subroutines CODE
PACKAGE - Definitions use Net::LDAP; INITIALIZING $ldap = Net::LDAP->new ( "yourLDAPhost.yourCompany.com" ) or die "$@"; BINDING $mesg = $ldap->bind ( version => 3 ); # use for searches $mesg = $ldap->bind ( "$userToAuthenticate", password => "$passwd", version => 3 ); # use for changes/edits # see your LDAP administrator for information concerning the # user authentication setup at your site. OPERATION - Generating a SEARCH sub LDAPsearch { my ($ldap,$searchString,$attrs,$base) = @_; # if they don't pass a base... set it for them if (!$base ) { $base = "o=mycompany, c=mycountry"; } # if they don't pass an array of attributes... # set up something for them if (!$attrs ) { $attrs = [ 'cn','mail' ]; } my $result = $ldap->search ( base => "$base", scope => "sub", filter => "$searchString", attrs => $attrs ); } my @Attrs = ( ); # request all available attributes # to be returned. my $result = LDAPsearch ( $ldap, "sn=*", @Attrs ); PROCESSING - Displaying SEARCH Results #------------ # # Accessing the data as if in a structure # i.e. Using the "as_struct" method # my $href = $result->as_struct; # get an array of the DN names my @arrayOfDNs = keys %$href; # use DN hashes # process each DN using it as a key foreach ( @arrayOfDNs ) { print $_, " "; my $valref = $$href{$_}; # get an array of the attribute names # passed for this one DN. my @arrayOfAttrs = sort keys %$valref; #use Attr hashes my $attrName; foreach $attrName (@arrayOfAttrs) { # skip any binary data: yuck! next if ( $attrName =~ /;binary$/ ); # get the attribute value (pointer) using the # attribute name as the hash my $attrVal = @$valref{$attrName}; print " $attrName: @$attrVal "; } print "#------------------------------- "; # End of that DN } # # end of as_struct method # #-------- #------------ # # handle each of the results independently # ... i.e. using the walk through method # my @entries = $result->entries; my $entr; foreach $entr ( @entries ) { print "DN: ", $entr->dn, " "; my $attr; foreach $attr ( sort $entr->attributes ) { # skip binary we can't handle next if ( $attr =~ /;binary$/ ); print " $attr : ", $entr->get_value ( $attr ) ," "; } print "#------------------------------- "; } # # end of walk through method #------------ OPERATION - Modifying entries # # Modify # # for each of the modifies below you'll need to supply # a full DN (Distinguished Name) for the $dn variable. # example: # cn=Jo User,ou=person,o=mycompany,c=mycountry # # I would recommend doing a search (listed above) # then use the dn returned to populate the $dn variable. # # Do we only have one result returned from the search? if ( $result->count != 1 ) { exit; } # Nope.. exit my $dn = $entries[0]->dn; # yes.. get the DN ####################################### # # MODIFY using a HASH # my %ReplaceHash = ( keyword => "x", proxy => "x" ); my $result = LDAPmodifyUsingHash ( $ldap, $dn, \%ReplaceHash ); sub LDAPmodifyUsingHash { my ($ldap, $dn, $whatToChange ) = @_; my $result = $ldap->modify ( $dn, replace => { %$whatToChange } ); return $result; } ####################################### # # MODIFY using a ARRAY List # my @ReplaceArrayList = [ 'keyword', "xxxxxxxxxx", 'proxy' , "yyyyyyyyyy" ]; my $result = LDAPmodifyUsingArrayList ( $ldap, $dn, @ReplaceArrayList ); sub LDAPmodifyUsingArrayList { my ($ldap, $dn, $whatToChange ) = @_; my $result = $ldap->modify ( $dn, changes => [ replace => @$whatToChange ] ); return $result; } ####################################### # # MODIFY using a ARRAY # my @ReplaceArray = ( 'keyword', "xxxxxxxxxx" , 'proxy' , "yyyyyyyyyy" ); my $result = LDAPmodifyUsingArray ( $ldap, $dn, @ReplaceArray ); sub LDAPmodifyUsingArray { my ($ldap, $dn, $whatToChange ) = @_; my $result = $ldap->modify ( $dn, changes => [ replace => [ @$whatToChange ] ] ); return $result; } ####################################### # # MODIFY an existing record using 'Changes' # (or combination of add/delete/replace) # my @whatToChange; my @ReplaceArray; my @DeleteArray; my @AddArray; push @AddArray, 'cn', "me myself"; push @ReplaceArray, 'sn', '!@#$%^&*()__+Hello THere'; push @ReplaceArray, 'cn', "me myself I"; push @DeleteArray, 'cn', "me myself"; if ( $#ReplaceArray > 0 ) { push @whatToChange, 'replace'; push @whatToChange, @ReplaceArray; } if ( $#DeleteArray > 0 ) { push @whatToChange, 'delete'; push @whatToChange, @DeleteArray; } if ( $#AddArray > 0 ) { push @whatToChange, 'add'; push @whatToChange, @AddArray; } $result = LDAPmodify ( $ldap, $dn, @whatToChange ); sub LDAPmodify { my ($ldap, $dn, $whatToChange) = @_; my $result = $ldap->modify ( $dn, changes => [ @$whatToChange ] ); return $result; } OPERATION - Changing the RDN my $newRDN = "cn=Joseph User"; my $result = LDAPrdnChange ( $ldap, $dn, $newRDN, "archive" ); sub LDAPrdnChange { my ($ldap,$dn,$whatToChange,$action) = @_; my $branch; # # if the archive action is selected, move this # entry to another place in the directory. # if ( $action =~ /archive/i ) { $branch = "ou=newbranch, o=mycompany, c=mycountry"; } # # use the 'deleteoldrdn' to keep from getting # multivalues in the NAMING attribute. # in most cases that would be the 'CN' attribute # my $result = $ldap->moddn ( $dn, newrdn => $whatToChange, deleteoldrdn => '1', newsuperior => $branch ); return $result; } OPERATION - Adding a new Record my $DNbranch = "ou=bailiwick, o=mycompany, c=mycountry"; # # check with your Directory Schema or Administrator # for the correct objectClass... I'm sure it'll be different # my $CreateArray = [ objectClass => [ "top", "person", "organizationalPerson", "inetOrgPerson" ], cn => "Jane User", uid => "0000001", sn => "User", mail => "JaneUser@mycompany.com" ]; # # create the new DN to look like this # " cn=Jo User + uid=0000001 , ou=bailiwick, o=mycompany, c=mycountry " # # NOTE: this DN MUST be changed to meet your implementation # my $NewDN = "@$CreateArray[2]=". "@$CreateArray[3]+". "@$CreateArray[4]=". "@$CreateArray[5],". $DNbranch; LDAPentryCreate($ldap, $NewDN, $CreateArray); # # CreateArray is a reference to an anonymous array # you have to dereference it in the subroutine it's # passed to. # sub LDAPentryCreate { my ($ldap, $dn, $whatToCreate) = @_; my $result = $ldap->add ( $dn, attrs => [ @$whatToCreate ] ); return $result; } ERROR - Retrieving and Displaying ERROR information if ( $result->code ) { # # if we've got an error... record it # LDAPerror ( "Searching", $result ); } sub LDAPerror { my ($from, $mesg) = @_; print "Return code: ", $mesg->code; print " Message: ", $mesg->error_name; print " :", $mesg->error_text; print "MessageID: ", $mesg->mesg_id; print " DN: ", $mesg->dn; #--- # Programmer note: # # "$mesg->error" DOESN'T work!!! # #print " Message: ", $mesg->error; #----- } UNBIND $ldap->unbind; LDAP SCHEMA RETRIEVAL
The following code snippet shows how to retrieve schema information. The first procedure is to initialize a new LDAP object using the same procedures as listed at the beginning of this document. The second procedure is to bind to your directory server. Some servers may require authentication to retrieve the schema from the directory server. This procedure is listed at the beginning of this document too. After a successful bind you are ready to retrieve the schema information. You do this by initializing a schema object. $schema = $ldap->schema ( ); In this case Net::LDAP will attempt to determine the dn under which the schema can be found. First it will look for the attribute "subschemasubentry" in the root DSE. If that cannot be found then it will default to the assumption of "cn=schema" Alternatively you can specify the dn where the schema is to be found with $schema = $ldap->schema ( dn => $dn ); Once we have a dn to search for, Net::LDAP will fetch the schema entry with $mesg = $self->search ( base => $dn, scope => 'base', filter => '(objectClass=subschema)', ); Once the schema object has been initialized, schema methods are used to retrieve the data. There are a number of ways this can be done. Information on the schema methods can be found in the Net::LDAP::Schema pod documentation. The following is a code snippet showing how to get and display information about returned attributes. # # Get the attributes # @attributes = $schema->all_attributes ( ); # # Display the attributes # foreach $ar ( @attributes ) { print "attributeType: ", $ar->{name}, " "; # # Print all the details # foreach $key ( keys %{$ar} ) { print join ( " ", " $key:", ref ( $ar->{$key} ) ? @{$ar->{$key}} : $ar->{$key} ), " "; } } The process is the basically the same for getting objectClass information. Where schema->all_attributes() is used, substitute schema->all_objectclasses(). From that point on the process is the same for both objectClasses and attributes. BUGS
None known, but there may be some AUTHOR
(of this document) Russell Biggs <rgb@ticnet.com> COPYRIGHT
All rights to this document are hereby relinquished to Graham Barr. perl v5.16.2 2012-09-20 Net::LDAP::Examples(3)
All times are GMT -4. The time now is 09:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy