I have the below script which is working in the terminal but not in crontab.Why it is not running in cron
Note:/opt/app/bin/app.exe is having a CLI
#!/bin/bash
PATH=/opt/app/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/myuser/.local/bin:/home/myuser/bin:/home/myuser/scripts
ip=10.12.13.4
file=filename
function filestats(){
/usr/bin/expect - $1 $2 << 'EOF' | awk '/^second line/ { print $5 }'
set ip [lindex $argv 0]
set file [lindex $argv 1]
set timeout 60
spawn /opt/app/bin/app.exe 127.0.0.1 $ip 1112
expect {
"CLI# > " { send "addip $file\r" }
}
sleep 3
expect {
"CLI# > " { send "quit\r" }
}
EOF
}
filestats ${ip} ${file}