I've found solution here:
http://www.wellho.net/forum/The-Tcl-...with-cron.html
that guy had the exact same problem (eof) and solved it by removing 'expect_after timeout'.
it works now but is there a way to keep the timeout?
edit:
solved completely by putting command 'expect_after timeout' at end of script, like this:
Code:
#!/usr/bin/expect
# exp_internal 1
# unset -nocomplain ::env(SSH_AUTH_SOCK) ;# This one is session-bound anyway
# puts[list array set ::env [array get ::env]]
# set env(PATH) "/home/dj/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
set verbose 0
set env(TERM) vt100
set env(SHELL) /bin/bash
set env(HOME) /home/dj
#If it all goes pear shaped the script will timeout after 5 seconds.
set timeout 5
#assigned to the variable name
set name [lindex $argv 0]
#assigned to the variable password
set password "eqz0fsRMBsnjihy"
#This spawns the telnet program and connects it to the variable name
spawn /usr/bin/telnet $name
#The script expects Password
expect "Password: "
#The script sends the password variable
send "$password\n"
send "sys diag\n"
send "show all\n"
send "ip status\n"
send "ip route status\n"
send "ip arp status\n"
send "ip ifconfig\n"
send "wan adsl linedata near\n"
send "wan adsl linedata far\n"
send "wan adsl txgain\n"
send "wan adsl farituid\n"
send "wan adsl nearituid\n"
send "sys countrycode\n"
send "sys atsh\n"
send "sys upnp display\n"
send "show wan adsl annex\n"
send "show wan adsl opmode\n"
send "wan adsl txfilter\n"
send "wan adsl targetnoise\n"
send "exit\n"
# send "sys view autoexec.net\n\n"
#This hands control of the keyboard over to you (Nice expect feature!)
# interact
expect_after timeout {puts "Timeout, exiting....";exit 0}
expect eof
exit
# set reboot
# sys diag
# sys view autoexec.net
# sys log disp y/n?
# send "sys display\n"
# iskljuci wifi: rtwlan disableap