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.
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.