My script is working but it's not reading the next line of the file .it is giving output for only one user not providing for next user from the users.txt file
#!/bin/bash
# Read the file containing the list of users to check
input_file="users.txt"
# Create empty files to hold the output
found_file="users_found.txt"
not_found_file="users_not_found.txt"
echo "" > $found_file
echo "" > $not_found_file
# Loop through each user in the input file
while read user; do
# Try to run the ldapsearch command for the user
if ssh -n ldaptest /opt/ldap/ldapsearch --user $user >/dev/null 2>&1; then
# User was found in LDAP, so append to the found file
echo "$user" >> $found_file
else
# User was not found in LDAP, so append to the not found file
echo "$user" >> $not_found_file
fi
done < $input_file
The above script will check user is available in ldap or not.if user is available in ldap then it sends its output to found_file else it will send user to not_found_file here it's not reading input on second line.
cat -vet users.txt
Testuser1 $
Testuser1 $
Testuser3 $
Testuser4 $