免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 990 | 回复: 0
打印 上一主题 下一主题

Expect, cron & telnet - solved [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-07-02 15:08 |只看该作者 |倒序浏览


  • 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP