What I am trying to do is create a sort of virtual file.
I've already tried using the here document and it doesn't seem to be working for me. What I am trying to do exactly is create an LDIF file for passing to an LDAP database. I have each line stored in an individual shell variable like so:
line1="dn: uid=$1,ou=Computers,dc=microverse,dc=net";
line2="objectClass: top"
line3="objectClass: account"
line4="objectClass: posixAccount"
line5="uidNumber: $store"
line6="uid: $1"
line7="cn: $1"
line8="gidNumber: $groupnum"
line9="homeDirectory: /dev/null"
line10="loginShell: /bin/false"
line11="gecos: Machine Account"
line12="description: Machine Account"
The syntax I've been trying looks like this:
ldapadd -x -D $binddn -w "placepasswordhere" <<hrdoc
line1="dn: uid=$1,ou=Computers,dc=microverse,dc=net";
line2="objectClass: top"
line3="objectClass: account"
line4="objectClass: posixAccount"
line5="uidNumber: $store"
line6="uid: $1"
line7="cn: $1"
line8="gidNumber: $groupnum"
line9="homeDirectory: /dev/null"
line10="loginShell: /bin/false"
line11="gecos: Machine Account"
line12="description: Machine Account"
hrdoc
I've also tried it with newlines at the end of each line like so:
ldapadd -x -D $binddn -w "placepasswordhere" <<hrdoc
line1="dn: uid=$1,ou=Computers,dc=microverse,dc=net\n";
line2="objectClass: top\n"
line3="objectClass: account\n"
line4="objectClass: posixAccount\n"
line5="uidNumber: $store\n"
line6="uid: $1\n"
line7="cn: $1\n"
line8="gidNumber: $groupnum\n"
line9="homeDirectory: /dev/null\n"
line10="loginShell: /bin/false\n"
line11="gecos: Machine Account\n"
line12="description: Machine Account\n"
hrdoc
In all cases the here document doesn't seem to make it to the ldapadd command which I know reads from standard-in. I've also tried the -f switch which is for specifiying a filename.
Anybody got a clue here?
jipe wrote:
On Sun, 12 Jan 2003 09:15:50 -0800 Mark Alexander <[EMAIL PROTECTED]> wrote:On Sat, Jan 11, 2003 at 05:56:16PM -0800, Jim C wrote:I have a list of positive integers of which I only want the first one. They are of arbitrary size. How can I cut the rest of them off? I've been trying to write a regular expression for this using sed or awk.#!/bin/sh LIST="42 666 1776 2001" echo $LIST | sed -e 's/^\([0-9]*\).*/\1/'
LIST="42 666 1776 2001"
echo ${LIST%% *} --> 42
or
LIST=(42 666 1776 2001)
echo ${LIST[0]} --> 42
both are about 5 times faster than a pipe with sed.
bye
jipe
------------------------------------------------------------------------
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com