File: reprompt

package info (click to toggle)
expect 5.45.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,016 kB
  • sloc: ansic: 17,965; sh: 7,445; tcl: 384; makefile: 191; exp: 10
file content (25 lines) | stat: -rw-r--r-- 472 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
exec tclsh "$0" ${1+"$@"}

package require Expect

# Name: reprompt
# Description: reprompt every so often until user enters something
# Usage: reprompt timeout prompt
# Author: Don Libes, NIST

foreach {timeout prompt} $argv {}

send_error $prompt
expect {
    timeout {
	send_error "\nwake up!!\a"
	send_error \n$prompt
	exp_continue
    }
    -re .+ {
	send_user $expect_out(buffer)
    }
}