0

I'm trying to write a script to loop through two different lists :

list 1 : list of servers
list 2 : list of users

I want to loop through the list of servers in list 1 and check the status of the user accounts in list 2 on each server.

This is what I have so far, but the inner loop is only checking the first account in the list on each server, then going back to the "outer loop" of servers. So I'm halfway there, I guess?

This is my script so far:

#!/bin/bash

unset SERVER unset USER

while IFS= read -r SERVER; do echo "$SERVER" while IFS= read -r USER; do ssh "$SERVER" "/usr/bin/lastlog -u $USER" done < /path/to/list_of_users.lst done < /path/to/list_of_servers.lst

I can't seem to figure out where I'm going wrong here. Any advice would be appreciated!

Andi
  • 51

0 Answers0