- 论坛徽章:
- 0
|
- From: Eric Sisler
- To: redhat-list redhat com
- Cc: Mark Enzinas
- Subject: Expect, cron & telnet - solved
- Date: Tue, 16 Feb 1999 09:26:11 -0700
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 Enzinas for 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.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/5591/showart_332458.html |
|