Article 5NEES Bash script assistance for loop

Bash script assistance for loop

by
bkone
from LinuxQuestions.org on (#5NEES)
I have a text file that is formatted like this
LDAP ad-group1
LDAP ad-group2
LDAP ad-group3
... etc

I am trying to run this command against all the lines of the text file using this:
Code:for name in $(cat /tmp/adgroup_file.txt); do mon query ls hosts -c name contact_groups -ct $name; done > output.txtNothing is being sent to the output.txt file it is just blank. I tried to add '' around the command 'mon query ls host -c name contact_groups -ct' $name but then I get
-bash: mon query ls hosts -c name contact_groups -ct: command not found

If I manually run Code:mon query ls hosts -c name contact_groups -ct 'LDAP ad_group' I get the information I want. Just trying to automate this a bit as I have over 100 AD groups I need to query.

Ideally it would be nice to have the export of each AD group to have a contact_groups listing in a separate file but just trying to get the basics working first.latest?d=yIl2AUoC8zA latest?i=10Glo63QDK0:Dpud9JD1HRY:F7zBnMy latest?i=10Glo63QDK0:Dpud9JD1HRY:V_sGLiP latest?d=qj6IDK7rITs latest?i=10Glo63QDK0:Dpud9JD1HRY:gIN9vFw10Glo63QDK0
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments