OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [expect/] [example/] [weather] - Blame information for rev 1776

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#!../expect -f
2
 
3
# weather - Expect script to get the weather (courtesy University of Michigan)
4
# Don Libes
5
# Version 1.9
6
 
7
# local weather is retrieved if no argument
8
# argument is the National Weather Service designation for an area
9
# I.e., WBC = Washington DC (oh yeah, that's obvious)
10
 
11
exp_version -exit 5.0
12
 
13
if $argc>0 {set code $argv} else {set code "WBC"}
14
 
15
proc timedout {} {
16
        send_user "Weather server timed out.  Try again later when weather server is not so busy.\n"
17
        exit 1
18
}
19
 
20
# delete special weather statement question
21
proc delete_special {s} {
22
        set x [string first "     ******" $s]
23
        return [join [lrange [split $s ""] 0 $x] ""]
24
}
25
 
26
set timeout 60
27
log_user 0
28
 
29
set env(TERM) vt100     ;# actual value doesn't matter, just has to be set
30
 
31
spawn telnet downwind.sprl.umich.edu 3000
32
match_max 100000
33
for {} 1 {} {
34
        expect timeout {
35
                send_user "failed to contact weather server\n"
36
                exit
37
        } "Press Return to continue*" {
38
               # this prompt used sometimes, eg, upon opening connection
39
               send "\r"
40
        } "Press Return for menu*" {
41
               # this prompt used sometimes, eg, upon opening connection
42
               send "\r"
43
        } "M to display main menu*" {
44
                # sometimes ask this if there is a weather watch in effect
45
                send "M\r"
46
        } "Change scrolling to screen*Selection:" {
47
                break
48
        } eof {
49
                send_user "failed to telnet to weather server\n"
50
                exit
51
        }
52
}
53
send "C\r"
54
expect timeout timedout "Selection:"
55
send "4\r"
56
expect timeout timedout "Selection:"
57
send "1\r"
58
expect timeout timedout "Selection:"
59
send "1\r"
60
expect timeout timedout "city code:"
61
send "$code\r"
62
expect $code            ;# discard this
63
 
64
for {} 1 {} {
65
        expect timeout {
66
                timedout
67
        } "Press Return to continue*:*" {
68
                send_user "\n[delete_special $expect_out(buffer)]\n"
69
                send "\r"
70
        } "Press Return to display statement, M for menu:*" {
71
                send_user "\n[delete_special $expect_out(buffer)]\n"
72
                send "\r"
73
        } -re "(.*)CITY FORECAST MENU.*Selection:" {
74
                send_user "\n$expect_out(1,string)\n"
75
                break
76
        }
77
}
78
 
79
send "X\r"
80
expect
81
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.