I have a shell script which runs an expect script which, in turn, connects to my router and reboots it. I've had something very like it for ages but I've had a problem ever since a recent upgrade to RH7.2.
Basically, the script works fine in the foreground; it works fine under "at now +1 minute"; it works fine under "batch" BUT it always fails when run under cron.
The relevant output from failed jobs looks like:
---------------------------------------------------------------------- spawn telnet my-router Trying 192.168.0.254... Connected to my-router. Escape character is '^]'.
Password: Connection closed by foreign host. send: spawn id exp3 not open while executing "exp_send -s -- $arg" (procedure "send" line 3) invoked from within "send -- "X"" (file "/usr/local/sbin/reboot_router.exp" line 53) ----------------------------------------------------------------------
which seems to show that the telnet session is spawned OK and opens the connection (the "Password: " string comes from the router) but then as soon as expect tries to send the first character of the password, it finds that the telnet session has been closed!
Any ideas, please?
PS. Yes, I know all of the security risks in embedding passwords in scripts and in using telnet rather than ssh!
Regards
Andrew Wallis Fox Cottage Fox Hill St Cross South Elmham HARLESTON IP20 0NX UK
tel: +44 (0)1986 782283 mobile: +44 (0)7860 217025 SMS via email: mailto: +447860217025@mmail.co.uk