1RUNSCRIPT(1) General Commands Manual RUNSCRIPT(1)
2
3
4
6 runscript - script interpreter for minicom
7
9 runscript scriptname [logfile [homedir]]
10
12 runscript is a simple script interpreter that can be called from within
13 the minicom communications program to automate tasks like logging in to
14 a unix system or your favorite bbs.
15
17 The program expects a script name and optionally a filename and the
18 user's home directory as arguments, and it expects that it's input and
19 output are connected to the "remote end", the system you are connecting
20 to. All messages from runscript meant for the local screen are directed
21 to the stderr output. All this is automatically taken care of if you
22 run it from minicom. The logfile and home directory parameters are
23 only used to tell the log command the name of the logfile and where to
24 write it. If the homedir is omitted, runscript uses the directory found
25 in the $HOME environment variable. If also the logfile name is omitted,
26 the log commands are ignored.
27
29 Runscript recognizes the following commands:
30
31 expect send goto gosub return !
32 exit print set inc dec if
33 timeout verbose sleep break call log
34
35
37 send <string>
38 <string> is sent to the modem. It is followed by a '\r'. <string>
39 can be:
40 - regular text, e.g. 'send hello'
41 - text enclosed in quotes, e.g. 'send "hello world"'
42
43 Within <string> the following sequences are recognized:
44 \n - newline
45 \r - carriage return
46 \a - bell
47 \b - backspace
48 \c - don't send the default '\r'.
49 \f - formfeed
50 \^ - the ^ character
51 \o - send character o (o is an octal number)
52
53 Control characters can be used in the string with the ^ prefix (^A
54 to ^Z, ^[, ^ ^], ^^ and ^_). If you need to send the ^ character,
55 you must prefix it with the \ escape character.
56 Also $(environment_variable) can be used, for example $(TERM).
57 Minicom passes three special environment variables: $(LOGIN),
58 which is the username, $(PASS), which is the password, as defined
59 in the proper entry of the dialing directory, and $(TERMLIN) which
60 is the number of actual terminal lines on your screen (that is,
61 the statusline excluded).
62
63 print <string>
64 Prints <string> to the local screen. Default followed by '\r\n'.
65 See the description of 'send' above.
66
67 label:
68 Declares a label (with the name 'label') to use with goto or
69 gosub.
70
71 goto <label>
72 Jump to another place in the program.
73
74 gosub <label>
75 Jumps to another place in the program. When the statement 'return'
76 is encountered, control returns to the statement after the gosub.
77 Gosub's can be nested.
78
79 return
80 Return from a gosub.
81
82 ! <command>
83 Runs a shell for you in which 'command' is executed. On return,
84 the variable '$?' is set to the exit status of this command, so
85 you can subsequently test it using 'if'.
86
87 exit [value]
88 Exit from "runscript" with an optional exit status. (default 1)
89
90 set <variable> <value>
91 Sets the value of <variable> (which is a single letter a-z) to the
92 value <value>. If <variable> does not exist, it will be created.
93 <value> can be a integer value or another variable.
94
95 inc <variable>
96 Increments the value of <variable> by one.
97
98 dec <variable>
99 Decrements the value of <variable> by one.
100
101 if <value> <operator> <value> <statement>
102 Conditional execution of <statement>. <operator> can be <, >, !=
103 or =. Eg, 'if a > 3 goto exitlabel'.
104
105 timeout <value>
106 Sets the global timeout. By default, 'runscript' will exit after
107 120 seconds. This can be changed with this command. Warning: this
108 command acts differently within an 'expect' statement, but more
109 about that later.
110
111 verbose <on|off>
112 By default, this is 'on'. That means that anything that is being
113 read from the modem by 'runscript', gets echoed to the screen.
114 This is so that you can see what 'runscript' is doing.
115
116 sleep <value>
117 Suspend execution for <value> seconds.
118
119 expect
120 expect {
121 pattern [statement]
122 pattern [statement]
123 [timeout <value> [statement] ]
124 ....
125 }
126 The most important command of all. Expect keeps reading from the
127 input until it reads a pattern that matches one of the specified
128 ones. If expect encounters an optional statement after that pat‐
129 tern, it will execute it. Otherwise the default is to just break
130 out of the expect. 'pattern' is a string, just as in 'send' (see
131 above). Normally, expect will timeout in 60 seconds and just
132 exit, but this can be changed with the timeout command.
133
134 break
135 Break out of an 'expect' statement. This is normally only useful
136 as argument to 'timeout' within an expect, because the default
137 action of timeout is to exit immediately.
138
139 call <scriptname>
140 Transfers control to another scriptfile. When that scriptfile fin‐
141 ishes without errors, the original script will continue.
142
143 log <text>
144 Write text to the logfile.
145
147 If you want to make your script to exit minicom (for example when you
148 use minicom to dial up your ISP, and then start a ppp or slip session
149 from a script), try the command "! killall -9 minicom" as the last
150 script command. The -9 option should prevent minicom from hanging up
151 the line and resetting the modem before exiting.
152 Well, I don't think this is enough information to make you an experi‐
153 enced 'programmer' in 'runscript', but together with the examples it
154 shouldn't be too hard to write some useful script files. Things will be
155 easier if you have experience with BASIC. The minicom source code
156 comes together with two example scripts, scriptdemo and unixlogin.
157 Especially the last one is a good base to build on for your own
158 scripts.
159
161 minicom(1)
162
164 Runscript should be built in to minicom.
165
167 Miquel van Smoorenburg, <miquels@drinkel.ow.org> Jukka Lahtinen,
168 <walker@netsonic.fi>
169
170
171
172User's Manual $Date: 2007-10-07 18:13:51 $ RUNSCRIPT(1)