Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5361476
  • 博文数量: 1144
  • 博客积分: 11974
  • 博客等级: 上将
  • 技术积分: 12312
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-13 20:06
文章存档

2017年(2)

2016年(14)

2015年(10)

2014年(28)

2013年(23)

2012年(29)

2011年(53)

2010年(86)

2009年(83)

2008年(43)

2007年(153)

2006年(575)

2005年(45)

分类: LINUX

2007-07-02 15:08:23

  • 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.
阅读(2377) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~