Quote:
Originally Posted by druuna
I don't have any experience with TCL but most of the problems when running a script from cron have to do with environment settings.
When running a script from the command line it has access to a fully set environment and parts of the script might make use of those settings. When running that script from cron, the environment that is set is minimal and thus the script might not work.
Make sure that all that is needed is set/present in the script.
If you are unsure, post the TCL script. I'm sure there are some people on this board that can help you with specifics.
|
The TCL code is real simple. Here it is.
1 #!/usr/bin/tclsh
2 package require Expect
3 set modem "192.168.13.31"
4 set timeout 30
5 log_user 0
6 proc state {arg} {
7 if {$arg == 1} {
8 puts "Modem will reboot"
9 set systemTime [clock seconds]
10 puts [clock format $systemTime -format {%Y,%m,%d %H:%M:%S}]
11 send "atz\r"
12 expect "\nOK"
13 exit
14 #send "^]\r"
15 #expect "\ntelnet>"
16 #send "q\r"
17 }
18 if {$arg == 0} {
19 puts "Modem is ready"
20 exit
21 }
22 }
23 spawn telnet $modem 2332
24 expect "\nPassword: "
25 send "12345\r"
26 expect "\nOK"
27 send "at*netstate?\r"
28 interact {
29 -o -re
30 "\n.*Ready.*" {[state 1]}
31 "\n.*Dormant.*" {[state 0]}
32 }
It spawns a telnet to a modem and uses expect to find out the state and depending on the state, reboots the modem. Why would this not work with a crontab but works when run from the command prompt? really frustrating..