Hey all, I'm new to shell scripting and kinda struck here with some of the commands
Code:
#!/usr/bin/expect
spawn ssh dmin@host
expect "password"
send "mypassword\n"
send "command1\n"
send "command2\n"
Interact
I write this simple code for 1 remote host and its working fine
Code:
#!/usr/bin/expect
for host in $(cat SERVERS);
do
spawn ssh dmin@host
expect "password"
send "mypassword\n"
send "command1\n"
send "command2\n"
Interact
EOF
done
However I want to execute the same command to over 20 hosts. Im having some trouble with the it. Is there any recommendation? If I want to use cat function and for loop is this possible and if yes how should I write it? I receive error: "cant' read "(cat hosts)"; no such variable
**btw Im using cygwin terminal to execute the script