0

trying to create small bash script. It will connect to multiple servers (inserted in txt file) and send a command, then output will be in output.txt.

Seems it doesn't work, I have something bad. Can you show me the right way?

script.sh

while read -r line
do
echo "Connecting to $line"
sshpass -p mypassword ssh -o StrictHostKeyChecking=no user@$line "/ls >> output.txt;
done < "servers.txt"
sover
  • 11
  • 4
  • "Doesn't work" is too vague to be actionable. That said, it would help to close your quotes, and redirect stdin to the copy of ssh from `/dev/null` so it doesn't consume content meant for the `read`. – Charles Duffy Jan 24 '20 at 16:31
  • ...for that second one, we already have duplicates in the knowledgebase. The first strikes me as a typo, which are off-topic here by nature. – Charles Duffy Jan 24 '20 at 16:31

0 Answers0