Date: Sun, 19 Mar 1995 16:26:51 -0800 (PST) From: Poul-Henning Kamp <phk@ref.tfs.com> To: hackers@FreeBSD.org Subject: using expect to dial... Message-ID: <199503200026.QAA25163@ref.tfs.com>
next in thread | raw e-mail | index | archive | help
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 <phk@login.dknet.dk> -- TRW Financial Systems, Inc. 'All relevant people are pertinent' && 'All rude people are impertinent' => 'no rude people are relevant'
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503200026.QAA25163>