Пример скрипта входа ssh
Заходит по ssh и выполняет команду
./script <команда>
#!/usr/bin/expect -f set timeout 2 set USER "user1" set PASS "userpass" set HOST "192.168.0.6" # Начало сценария spawn ssh $USER@$HOST; expect { "(yes/no)?*" { send "yes\r" } } expect "word:" send "$PASS\r" expect "$*" send "sudo $argv\r" expect "$*" send "exit\r" expect eof
Обсуждение
Подскажите что делать если выдает ошибку:
test4.sh: line 7: spawn: command not found couldn't read file "{": no such file or directory test4.sh: line 11: (yes/no)?*: No such file or directory test4.sh: line 12: send: command not found test4.sh: line 13: syntax error near unexpected token `}' test4.sh: line 13: ` }'