I am writing a bash script that reads a file and for each item in column 1, runs a command on 2-column file. It needs to ssh into each hostname (column 1) and kill a PID (PID # in column 2). Here's the code I'm trying, which isn't working (NOTE: this example does not run the kill command but asks script to ps the PID):
while read host pid; do
/usr/bin/sshpass -f ~/.pw /usr/bin/ssh -q -o "StrictHostKeyChecking=no" -o ConnectTimeout=5 $host ps -ef| egrep -e $pid
done < $UNIQ_FILE
The $UNIQ_FILE is formatted like this:
192.168.22.199 55829
192.168.22.142 662
...
The script is running the command on the first line of the file, and then exits.