-1

I have 1 input file contains username and hostname example:

ID1  host1
ID2  host2
ID3  host3
ID4  host1

Totally no script created yet.

My Question How I can make the script read username and do ssh based on host to do ssh.

ssh -q $host 'grep $user /etc/passwd'

and it looping until finish.

Thank you in advanced very Appreciate

script read the input file and read column 1 and column 2 as a input and then loop until the all line in the input are read.

do have

output , will show the result based on the input ID and do ssh to get the output.

oguz ismail
  • 1
  • 16
  • 47
  • 69

2 Answers2

0
while read -r user host;
do
  echo "${user}" # The ID?
  `your code`
done < inputfile
itChi
  • 642
  • 6
  • 19
0

you don't need an entire script for this, simply try this:

$ cat filename.txt  | awk '{system("ssh "$2" grep "$1" /etc/passwd;")}'

or

$ cat filename.txt | awk '{system("ssh "$2" getent passwd "$1";")}'