[plug] `Expect` and `cron` <http://expect.nist.gov>
James Devenish
devenish at guild.uwa.edu.au
Thu Jan 6 09:07:58 WST 2005
Hi,
Does anyone here use `expect`, and is it anything other than a
nightmare? Its free documentation seems disproportionately effusive
about its usability. I don't have a copy of 'the book' so perhaps that
is why I have so little luck with it. I am not sure if UWA has 'the
book' (the library catalogue seems to be offline at the moment!).
Anyway, after much struggling to get any reasonable results last year,
I have the following residual problem that I would like to resolve:
- In the UNIX spirit, I would like to have a cron job that performs
some periodic activity using readily-available tools. Scripting is
acceptable but compiling code is not. A hurdle is that the task
involves queries upon a MySQL database.
- I am not sure how to do 'passwordless' MySQL access from the command
line. (What I mean by this is 'unattended access', not 'passwordless'
per se.)
- I am currently using `expect` to perform this task, because all the
command-line utilities supplied with MySQL 4 seem to require
passwords only as command-line arguments (argh!) or via TTY input
(hence the need to use `expect`).
- I can use `expect` to perform this function successfully when run
from a terminal, but it only works intermittently from `cron`. I am
not calling expect directly -- it is used within a short script, and
it is this latter script that I invoke. It *does* work at least one
day out of seven. (But the intermittent behaviour doesn't seem to
correlate with anything else.) I do not know why it works *entirely*
on some occasions and completely fails on others. I get no diagnostic
output from `expect` or `cron` -- the script simply exits with a
return code of 1.
- In order to get `expect` to work from a crontab, I export $TERM as
'vt100'. Should I use something else? (By the way, the cron job
currently runs as root, but I might be able to change that.)
I would be happy with:
- Other ways of using MySQL from the command line.
- Ways of making `expect` work reliably from cron.
PS. The database in question is not currently considered a candidate for
migration to PostgreSQL.
More information about the plug
mailing list