Esteemed colleagues,
I have written a small code where i'm storing some command output into two different variables and aspiring those two values to be printed under into different columns called "PreferredList IP's" & "DefaultServerList IP's".
there are Variables PLIST & DLIST,So, when i'm running the script i only see output under the first column and unable to get the data under second column. This looks weird to me, i don't know where i'm doing mistake..please do correct me..
#!/bin/sh
set -f # to prevent filename expansion
printf "=%.0s" $(seq 1 50)
printf "\n"
printf "%-30s : %10s\n" "PreferredList IP's" "DefaultServerList IP's" # print header
printf "=%.0s" $(seq 1 50) # print separator
printf "\n" # print newline
PLIST="$(ldapsearch -h mylap -x -b "ou=profile,o=cadence.com" "cn=*" preferredserverlist -LLL | awk '/preferredserverlist: / {print $2}')"
DLIST="$(ldapsearch -h myldap -x -b "ou=profile,o=cadence.com" "cn=*" defaultserverlist -LLL | awk '/defaultserverlist: / { print $2 }')"
printf "%-30s : %10s\n" "$PLIST" "$DLIST"
RESULT: while using debug mode, I saw the problem is both the varibale output coming into first column.
======================================================
PreferredList IP's : DefaultServerList IP's
========================================================
123.18.8.15
123.18.8.16
192.10.167.9
192.10.167.8
123.18.8.16
10.218.88.38
Below is the ldapsearch command output sample:
dn: cn=india, ou=profile, o=cadence.com preferredServerList: 123.18.8.15 123.18.8.16 defaultServerList: 123.18.8.16 123.18.8.15
dn: cn=japan, ou=profile, o=cadence.com preferredServerList: 192.10.167.9 192.10.167.8 defaultServerList: 123.18.8.16 10.218.88.38
$ ldapsearch -h myldap -x -b "ou=profile,o=cadence.com" "cn=*" preferredserverlist -LLL | awk '/preferredserverlist: / {print $2}' | head -2
123.18.8.15
123.18.8.16
$ ldapsearch -h myldap -x -b "ou=profile,o=cadence.com" "cn=*" defaultserverlist -LLL | awk '/defaultserverlist: / { print $2 }' | head -2
123.18.8.16
10.218.88.38
hexdump -C(or justhd). Also, your output doesn't match your code: your printf has a colon in the string and there are no colons in your output.