Xref: utzoo comp.sys.att:5196 comp.unix.questions:11046 Path: utzoo!utgpu!attcan!uunet!cucstud!aucis!bnick From: bnick@aucis.UUCP (Bill Nickless) Newsgroups: comp.sys.att,comp.unix.questions Subject: Scripting sh sessions Summary: This doesn't always work! Keywords: 6386, UNIX, cu Message-ID: <125@aucis.UUCP> Date: 11 Jan 89 00:40:40 GMT References: <9877@drutx.ATT.COM> <4861@mtgzz.att.com> Distribution: comp Lines: 40 In article <4861@mtgzz.att.com>, avr@mtgzz.att.com (a.v.reed) writes: > > In article <9877@drutx.ATT.COM>, csr@drutx.ATT.COM (Steve Roush) writes: > > For strictly interactive use, I use "cu". .... > > I do not know of any UNIX programs outside of AT&T that allow scripting > > of sessions as can be done under DOS. > > Oh yes you do, unless you've never heard of "tee". > And here is how you script a local sh session: > > $ tee -ia script.out | sh -is 2>&1 | tee -ia script.out Only one problem. Unless you are on a tty line, the standard I/O stuff such as printf buffer a solid 512 bytes. (That can be changed by adding a setbuf() line.) Consider the following program: ----cut here---- #include char s[80]; main() { printf("Enter a string:"); gets(s); printf("You entered:%s\n",s); } ----cut here---- When you execute it in the scripted session, you don't get the prompt "Enter a string:" until AFTER you've entered it! This of course can be fixed if you have the source, but that can't be assumed for every program. -- William (Bill) Kirk Nickless Andrews University 305 Meier Computer and Information Science Department Berrien Springs, MI 49104 UNIX Support Group (616) 471-6515 or (616) 471-3422 ...!uunet!cucstud!aucis!bnick