home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dove!cme!libes
- From: libes@cme.nist.gov (Don Libes)
- Newsgroups: comp.unix.shell
- Subject: Re: Simulating keyboard input in interactive programs
- Message-ID: <19291@muffin.cme.nist.gov>
- Date: 15 Sep 92 18:07:55 GMT
- References: <1992Sep10.163557.10186@siesoft.co.uk> <joslin.716216242@c0223.ae.ge.com> <1992Sep11.142202.11116@Princeton.EDU>
- Organization: National Institute of Standards and Technology
- Lines: 61
-
- In article <1992Sep11.142202.11116@Princeton.EDU> subbarao@fc.hp.com (Kartik Subbarao) writes:
- }In article <joslin.716216242@c0223.ae.ge.com> joslin_paul@ae.ge.com writes:
- }>>pdel@ADS.COM (Peter Delevoryas) writes:
- }>>: This is kind of related to #1. Our dial-in lines are set to
- }>>: auto-log out after about 20 min. of inactivity. Short of
- }>>: programming the terminal-server not to do this, how can I
- }>>: keep a process going so that it always seems like I'm doing
- }>>: something, even if I'm in the kitchen making a BLT (extra mayo).
- }>>: Just starting up some kind of loop won't do it; it has to be
- }>>: equal to a keypress from MY keyboard.
-
- }>If you're using a pc at home, what about a TSR that puts a "space-CR"
- }>in the keyboard buffer every five minutes?
- }
- }This would be a good solution, but you'd also want to put some checking
- }that the user was *idle* for five minutes. I can imagine it now:
- }
- }% rm -rf * [hmm, do I want to do this?]
- }% [ OH NO, my TSR hit return for me!!! ]
-
- }>Second, have you tried something like
-
- }>while :
- }>do
- }> sleep 3600
- }> echo "ls" > `tty`
- }>done
- }>
- }>where `tty` returns the tty device your shell is using.
- }
- }I quote again from the very article you replied to:
- }
- }>>: Just starting up some kind of loop won't do it; it has to be
- }>>: equal to a keypress from MY keyboard.
- }
- }Redirecting the output of echo to your tty simply writes the text 'ls' on
- }your terminal. Just as if you said "echo thousandlineslong" > `tty`. It
- }does NOT write to the input buffer of the tty. To do so, you can use the
- }TIOCSTI ioctl if you have it.
- }
- }Once again, please test your solutions before you post them.
- }
- } -Kartik
-
- Here's a tested solution.
-
- #!expect -f
- #Name: noidle
- #Description: expect script to run a shell which avoids being "autologged out"
- # by sending a <space><delete> every hour if no other I/O has occurred.
- #Author: Don Libes, December 30, 1991
-
- set timeout 3600
- log_user 0
- system stty -echo raw
- spawn $env(SHELL)
- expect {
- timeout {send " \177"; continue -expect}
- -re .+ {send_user -raw $expect_out(buffer); continue -expect}
- -i $user_spawn_id -re .+ {send $expect_out(buffer); continue -expect}
- }
-