i wrote an expect script to ssh remotely to multiple linux boxes and running this command chmod -R o-w /etc/ But i am getting an error expect: invalid option -- 'R'
Please find the script below
#!/bin/bash
username=$1
userpass=$2
rootpass=$3
cat server_list | while read host
do
expect -c "
set timeout 5
spawn ssh -o StrictHostKeyChecking=no -tq ${username}@${host} sudo su - root
expect "ssword" { send "${userpass}r" }
expect "ssword" { send "{rootpass}r" }
expect "#"
send "chmod -R o-w /etc"
expect "#" { send "exitr" }
expect eof"
done
i am running the script like this
./test1.sh test test@123 test@123
Kindly help