#! /usr/local/bin/expect -- #From: "Theo Lutgerink" #Date: Thu, 06 Mar 1997 05:41:09 # This script sends the given shell-command(s) to the shell, waits for # a timeout to repeat it, unless shell-activity is detected in the # meantime. Then counting starts again. Usable against idle-checks. Has # also some safety-checks built in. Exit with Ctrl-D or Esc or 'End-key'. proc usage {} { global argv0 puts -nonewline "\nUsage: [file tail $argv0]" puts -nonewline " \"\"\n\n" exit } switch $argc { 0 usage 1 usage 2 { if [catch { expr [lindex $argv 0] }] { usage else {} } } default usage } if {[string match "sleep*" [lindex $argv 1]] || \ [string match "[file tail $argv0]*" [lindex $argv 1]] } then \ {puts "\n\"[lindex $argv 1]\": Un[file tail $argv0]able instruction\n";exit} \ else {} spawn -noecho $env(SHELL) expect { -re ".+" { send -- "[lindex $argv 1]\r" } } interact { "\x1b\[5~" {send "\004"} "\x1b" {send "\004"} -o timeout [lindex $argv 0] {send -- "[lindex $argv 1]\r"} }