LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-31-2011, 10:33 AM   #1
tonyGedeon
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Rep: Reputation: 0
Question ldapmodify - return code


Hello,
I need to get a return code for the command
ldapmodify.
I try this and didn't work
rc=ldapmodify -a -v -c -p $PORT -h $SRV -D cn=$USR,cn=Users,dc=company,dc=com -w $PWD -f $LDIFFILENAMECOUNT
echo "return code " $rc

what exactly the way to get the return code of that ?

thanks
TG

Last edited by tonyGedeon; 03-31-2011 at 10:34 AM. Reason: wrong title should be ldapmodify - return code
 
Old 03-31-2011, 11:43 AM   #2
Medievalist
Member
 
Registered: Aug 2003
Distribution: Dead Rat
Posts: 191

Rep: Reputation: 56
Use bash internal variable $? to get exit status of commands

"Within bash, the special parameter $? is expanded to the exit status of the last executed command."

Keep in mind, if you pipeline several commands, the exit status of the last command to execute will be the return status of the entire pipeline. Also keep in mind that $? will be overwritten almost immediately if you don't save it off somewhere.

So, you can either save $? like this:

ldapsearch blah blah blah
rc=$?

or use a normal bash if/else structure like this:

if ldapsearch blah blah blah
then
do stuff if ldapsearch succeeds
else
do stuff if ldapsearch fails
fi

Remember, bash's "if" does not test for expression validity, like most languages - it tests for process success or failure. The use of the "test" command or brackets lets you provide success or failure based on expression evaluation, though.

Hope that helps!
 
1 members found this post helpful.
Old 03-31-2011, 12:13 PM   #3
tonyGedeon
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for your reply and the explanation.
but one more thing, if i have in my pipeline(its a file contains about 100 commands), how can i get for each one a exit status.
my file is like that.

dn: cn=3b65dd06-8f8c-4e1b-93c7-93e9bb000001,cn=users,dc=ca,dc=company,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetorgperson
objectClass: orcluser
objectClass: orcluserV2
objectClass: slexternaluser
objectClass: oblixorgperson
objectClass: oblixpersonpwdpolicy
cn: 3b65dd06-8f8c-4e1b-93c7-93e9bb000001
uid: M000001
userpassword: a915125c9d07aaf1
slaccessidentifier: M000001
slList1: M000001
slIVRUserID:
slIVRPassword: ckK7Jm5qaKJow
sluserregistrationdate: 20110308031623
orclisenabled: ENABLED
sn: M000001
slbusinessrole: Sales_Representative
slFlag10: true
slFlag1: true
slFlag7: true
slCLASPasswordChange: false

thanks again

TG

Last edited by tonyGedeon; 03-31-2011 at 12:21 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I test the return code value Glenn D. Linux - Software 2 01-28-2011 08:34 AM
dpkg return error :post installation script return an error code (1) grimfold Debian 2 09-10-2009 01:55 PM
wget return code ferp Programming 9 11-06-2008 12:37 PM
request_region(...) return code BrooklynOutlier Programming 0 03-07-2006 09:22 PM
dd return code barefootdoctor Linux - General 2 10-13-2005 12:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration