bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ldapscripts unusable from within a 'while read line' loop


From: Lakshminarasimhan Srinivasan
Subject: ldapscripts unusable from within a 'while read line' loop
Date: Thu, 01 Aug 2013 09:37:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VEND$ uname output: Linux win7082 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 37
Release Status: release

Description:
ldapscripts do not work from inside a "while read line" loop. The exact same scripts were working fine until the last upgrade

Repeat-By:
Prerequisite: ldapscripts installed.
Open a new bash script and type in the following:
-------------------------------------------------
#!/bin/bash
echo "Testing if it works outside of the loop"
ldapid
echo "Getting into the read line loop"
while read line
do
  ldapid
done <"Some file"
------------------------------------------------
The 'ldapid' command, which works outside of the loop, does not work from within. This time it throws an error "Cannot guess user". Now we check an alternative:
Create a new script and type in the following:
------------------------------------------------
#!/bin/bash
echo "Testing if it works outside of the loop"
ldapid
readarray lines < "some file"
echo "Getting into the for loop"
for line in "${lines[@]}"
do
  ldapid
done
-----------------------------------------------
In this case 'ldapid' works both times. In fact, ldapid works in every other loop except a 'while read line' and I really do not have any idea why.

Many thanks for having a look,
Laks




reply via email to

[Prev in Thread] Current Thread [Next in Thread]