stdout/stderr  redirection of  ldap command

avimal
avimal used Ask the Experts™
on
I am not able to redirect stdout and stderr of ldapmodify coommand to my local file.

ldapmodify -b -p 53890 -D ... -w mcOSLPasswd <<EOF
dn: TN=2342342342
changetype: modify
replace: all
SubscriberName:avimal
EOF > myfile 2>&1

ldapmodify doesn't accept this syntax. I have to use ldap command with << EOF ...EOF. How can I redirect its stdout/stderr to a file.

Thanks for any help.

Vimal



Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
jkr
Top Expert 2012

Commented:
>>ldapmodify doesn't accept this syntax

Output redirection is done by the shell, not by the program. Is the above really split into multiple lines?

Have you tried

<your command> | tee 2>&1 myfile

?

Author

Commented:
jkr,

Thanks for  your inputs.
I would like to emphasize on that fact that this problem seems to be due to <<EOF..EOF stuff. If I do ldapmodify -f myfile|tee 2> &1 myfile, it works. But when I use EOF, it
hangs as follows:

ms03(root)# ldapmodify -e -p 53890 -D cn=_OSL_,kind=applications -w mcOSLPasswd
<<EOF
dn: TN> =2342342342
chan> getype: modify
re> place: all
> SubscriberName:avimal
> EOF  | tee 2>&1 myfile
>
>

It interpretates, | tee ... also as attribute and value...don't know why?

Note I gave attributes in multiple lines meaning attribute:value then newline then next attribute.

Vimal
jkr
Top Expert 2012

Commented:
Hmm, would it work if you put the whole thing in a variable like

export LDAPCMD="ldapmodify -e -p 53890 -D cn=_OSL_,kind=applications -w mcOSLPasswd << EOF\ndn: TN> =2342342342 ... \nEOF"

$LDAPCMD | tee 2>&1 myfile

(replace the line break with '\n')
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Author

Commented:
jkr,

Thanks for  your inputs.
I would like to emphasize on that fact that this problem seems to be due to <<EOF..EOF stuff. If I do ldapmodify -f myfile|tee 2> &1 myfile, it works. But when I use EOF, it
hangs as follows:

ms03(root)# ldapmodify -e -p 53890 -D cn=_OSL_,kind=applications -w mcOSLPasswd
<<EOF
dn: TN> =2342342342
chan> getype: modify
re> place: all
> SubscriberName:avimal
> EOF  | tee 2>&1 myfile
>
>

It interpretates, | tee ... also as attribute and value...don't know why?

Note I gave attributes in multiple lines meaning attribute:value then newline then next attribute.

Vimal
Commented:
Try this sintax:

ldapmodify -b -p 53890 -D cn=_OSL_,kind=applications -w mcOSLPasswd <<EOF  > myfile 2>&1
dn: TN=2342342342
changetype: modify
replace: all
SubscriberName:avimal
EOF

Author

Commented:
Great, It works perfectly as expected.
Thanks,
Vimal

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial