From owner-freebsd-hackers Sun Mar 19 16:27:00 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id QAA26596 for hackers-outgoing; Sun, 19 Mar 1995 16:27:00 -0800 Received: from ref.tfs.com (ref.tfs.com [140.145.254.251]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id QAA26580; Sun, 19 Mar 1995 16:26:56 -0800 Received: (from phk@localhost) by ref.tfs.com (8.6.8/8.6.6) id QAA25163; Sun, 19 Mar 1995 16:26:51 -0800 From: Poul-Henning Kamp Message-Id: <199503200026.QAA25163@ref.tfs.com> Subject: using expect to dial... To: hackers@FreeBSD.org Date: Sun, 19 Mar 1995 16:26:51 -0800 (PST) Content-Type: text Content-Length: 1416 Sender: hackers-owner@FreeBSD.org Precedence: bulk Here is the small expect script I use to dial in to a cisco and start a slip session. It uses a little know feature of expect to talk directly to the tty-device. Hope somebody can use it: Poul-Henning #!/usr/local/bin/expect set device /dev/cuaa2 set speed 115200 set dial AT&M5&D3M2DT1234567 set user phk set upasswd Guess set machine flagmose set mpasswd Who set localip 192.216.222.24 set remoteip 192.216.222.11 set ntpip 140.145.250.1 proc EX str { expect $str "" \ timeout "exit 1" \ "BUSY" "exit 1" \ "NO DIAL TONE" "exit 1" \ "NO CARRIER" "exit 1" } set fd [open $device "r+"] stty $speed raw < $device spawn -open $fd set timeout 1 send "AT\r" expect "OK" "" send "AT\r" expect "OK" "" set timeout 60 send "$dial\r" EX "Username: " set timeout 15 send "$user\r" EX "Password: " send "$upasswd\r" EX ">" send "slip /c\r" EX "hostname: " send "$machine\r" EX "Password: " send "$mpasswd\r" EX "/compress." exec slattach -s $speed -c -h $device >&@ stdout exec ifconfig sl0 mtu 1500 >&@ stdout exec ifconfig sl0 $localip $remoteip up >&@ stdout exec route delete default >&@ stdout exec route add default $remoteip >&@ stdout exec sh -c "ping -c 3 $remoteip" >&@ stdout exec sh -c "ntpdate $ntpip" >&@ stdout -- Poul-Henning Kamp -- TRW Financial Systems, Inc. 'All relevant people are pertinent' && 'All rude people are impertinent' => 'no rude people are relevant'