0

I'm trying to SSH into a bunch of hosts in order, and run a command to get a list of users on each one. Outside of a for loop, the output shows up just fine one-by-one. Inside a for loop, it disappears. How do I make that output visible?

#!/bin/bash

#grab a bunch of IP addresses from a file
for address in $(cat ip_list.txt)


do

#output for this shows up.
echo "connecting to $address";

#output for this does not
sshpass -p 'password' ssh account@$address "echo $address;dscl . list /Users | grep -v '^_\|nobody\|daemon\|admin\|root'; exit"
done
Mark S
  • 1
  • I wonder if this relates to sshpass? What happens (other then needing to manually type the password each time) if you remove it? Also, what happens if you remove the exit at the end of the line? – davidgo Apr 30 '20 at 19:52
  • Good point, I'll give that a try. – Mark S Apr 30 '20 at 21:00
  • You nailed it.Now I need to figure out how to mark your answer as correct. – Mark S Apr 30 '20 at 23:28
  • I'm pleased it worked. There is nothing to mark correct as it was niy an answer, only a comment! – davidgo May 01 '20 at 00:54

0 Answers0