全部博文(1144)
分类: LINUX
2007-07-02 15:08:23
Awhile back I inquired about a problem running an expect script from cron: >I'm starting to write expect scripts to automate >some system administration tasks and I have one >that works fine unless I try to schedule it using cron. >I know it's because I'm trying to spawn a telnet session >and telnet complains if it has no controlling tty - this >is the error message I get: > >failed to get controlling terminal using TIOCSCTTYparent: >sync byte write: broken pipe Turns out a simple & elegant solution to the problem is to schedule a short perl script with cron: #!/usr/bin/perl -w system("/usr/bin/expect /some/path/expectscriptname"); Cron runs the perl script and perl runs the expect script. I don't know enough about perl yet to really explain how it works, but apparently perl essentially has access to the command line, so running the expect script in this way is like running it interactively at the command line. Guess it's time to learn more about perl! So far I have successfully used this method with a set of bash & expect scripts that spawn telnet & ftp connections. A big thanks to Mark Enzinasfor enlightening me. -Eric Eric Sisler Library Computer Technician Westminster Public Library Westminster, CO, USA esisler libris ci westminster co us Linux - don't fear the Penguin.