news.utdallas.edu!wupost!howland.reston.ans.net!usc!enterpoop.mit.edu!senator-bedfellow.mit.edu!athena.mit.edu!mkgray Mon Mar 15 14:45:49 CST 1993 Article: 1591 of comp.lang.perl Xref: feenix.metronet.com comp.lang.perl:1591 Path: feenix.metronet.com!news.utdallas.edu!wupost!howland.reston.ans.net!usc!enterpoop.mit.edu!senator-bedfellow.mit.edu!athena.mit.edu!mkgray From: mkgray@athena.mit.edu (Matthew K Gray) Newsgroups: comp.lang.perl #Subject: Re: Getting perl to do a telnet Date: 15 Mar 1993 18:49:38 GMT Organization: Massachusetts Institute of Technology Lines: 110 Distribution: world Message-ID: <1o2j42INN8cf@senator-bedfellow.MIT.EDU> References: NNTP-Posting-Host: podge.mit.edu Keywords: chat2, chat, telnet, geography The easiest way to do this is probably with the chat2.pl package. This is available all over the place by ftp. (eg, gatekeeper.dec.com:/contrib/src/crl/perl/src/lib/chat2.pl) Here is a sample of using chat2.pl that retrieves info from the geographical name server: ---cut here---cut here---cut here--- #!perl if($#ARGV < 0) {&usage();} sub usage { print("Usage:\n"); print("\tgeo place name\n"); exit(0); } require 'chat2.pl'; sub listen { local($secs) = @_; local($return,$tmp) = ""; while (length($tmp = &chat'expect($secs, '(.|\n)+', '$&'))) { print $tmp if $trace; $return .= $tmp; } $return; } # 0 # 1 # 2 # 3 # A # E # F # L # P <1980 census population> # R # T