Here is my expect script named as script.exp which runs successfully when executed from terminal. But it doesn't run when scheduling through cronjob.
#!/usr/bin/expect -f
set timeout -1
spawn /home/user1/sql_backup.sh
match_max 100000
expect -exact "Enter password: "
send -- "pass123\r"
expect eof
my bash script named as sql_backup.sh is:
#!/bin/bash
mysqldump -u root -p --all-databases > /home/user1/mysql/mysql-bkp.sql
and my cronjob is:
* * * * * /usr/bin/expect -f /home/user1/script.exp
Thanks