[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hpux-admin
Subject:    [HPADM] RE: string manipulation
From:       Jon Fraley <jfraley () glenraven ! com>
Date:       2001-11-29 21:09:09
[Download RAW message or body]

Thanks to those who replied.  It seems that there was nothing wrong with
what I was doing.  The problem lies in the string that I was returning.  It
seems to have a line feed character embedded at the 75th character.

Is there a way to strip that character out when I process it?

Thanks,

Jon Fraley
Unix Systems Administrator
Glen Raven, Inc
(336) 586-1148

 -----Original Message-----
From: 	hpux-admin-owner@dutchworks.nl
[mailto:hpux-admin-owner@dutchworks.nl]  On Behalf Of Jon Fraley
Sent:	Thursday, November 29, 2001 2:51 PM
To:	hpux-admin@dutchworks.nl
Subject:	[HPADM] string manipulation

I am trying to set up a script that will take a uid, return its
distinguished name(dn) from the ldap db and then delete that dn.  The
ldapsearch returns a string as:

dn: uid=DDuck,ou=Department-Burnsville, ou=Filament Fabrics Division, o=Glen
Raven Mills, c=US

I need to remove the "dn: " from the beginning of the string so it can be
passed to the ldapdelete statement.  The script works fine except when the
dn is greater than 74 characters.  I have tried three different ways to do
this and am getting incorrect strings around the 75th character for each
one.

Here's what I've got each with the displayed variable using echo:
This example the string dropped off after 74 characters.
DN=`ldapsearch -b "o=Glen Raven Mills, c=US" "(uid=$1)" dn|awk -F":" '{print
$2}'`
echo $DN
uid=DDuck,ou=Department-Burnsville, ou=Filament Fabrics Division, o=Glen R
This example the string changed the 75th and 76th characters to a space.
DN=`ldapsearch -b "o=Glen Raven Mills, c=US" "(uid=$1)" dn|cut -c 5-100`
echo $DN
uid=DDuck,ou=Department-Burnsville, ou=Filament Fabrics Division, o=Glen R n
Mills, c=US
This example a space was inserted after the 75th character.
DN=`ldapsearch -b "o=Glen Raven Mills, c=US" "(uid=$1)" dn`
echo ${DN##dn: }
uid=DDuck,ou=Department-Burnsville, ou=Filament Fabrics Division, o=Glen R
aven Mills, c=US

Is there a better way to do this or is it a HP-UX limitation?


Jon Fraley
Unix Systems Administrator
Glen Raven, Inc
(336) 586-1148


--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact
majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner:
owner-hpux-admin@dutchworks.nl

 Archives:  ftp.dutchworks.nl/pub/digests/hpux-admin       (FTP, browse
only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse &
search)


--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic