[btl.unix] a question on input redirection

spear@ihopb.UUCP (09/16/83)

I have been trying to come up with a generalized
way to direct input to a command such that it takes
it's input from a file for a while and then begins
taking input from the standard input (keyboard).
I am interested in having a repetitive series of
commands piped to a certain job after which I want
to enter further commands from the keyboard.  The
problem normally encountered in any scheme I have
tried is the reaching of end of file during the
initial input which causes the command to terminate.

I have tried various schemes of manipulating file
descriptors with no success.  Any suggestions would
be greatly appreciated.

Thanks in advances,


Steven Spearman
ihnp4!ihopb!spear

mark@umcp-cs.UUCP (09/18/83)

	I have been trying to come up with a generalized
	way to direct input to a command such that it takes
	it's input from a file for a while and then begins
	taking input from the standard input (keyboard).

If your command is 'cmd', why not:
	cat file1 file2 ... filen - | cmd
-- 
spoken:	mark weiser
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!mark
CSNet:	mark@umcp-cs
ARPA:	mark.umcp-cs@UDel-Relay

dave@utcsrgv.UUCP (Dave Sherman) (09/18/83)

How about
	cat file /dev/tty ^ your-program

That should send file, followed by whatever you type at the
terminal, to your program.

Dave Sherman
-- 
 {cornell,decvax,floyd,ihnp4,linus,utzoo,uw-beaver,watmath}!utcsrgv!lsuc!dave

spear@ihuxm.UUCP (09/19/83)

Thanks to all those who have suggested variations on the
cat file1 filen - | program
method for taking some input from a file then from the keyboard.
I was aware of this approach, but was hoping there was a more
elegant way of handling this.  My major concern with the use of
'cat' is the very real possibility of leaving the cat process
running if the program terminates on it's own (that is, not due
to an end of file from the termination of cat).  This can result
in strange occurrences where some of your input is taken by the
cat process and shipped to nowhere while the rest is taken by the
shell.

Thanks for all the responses.  Any other ideas would be welcome.

Steven G. Spearman
ihnp!ihopb!spear

mark@umcp-cs.UUCP (09/20/83)

	My major concern with the use of
	'cat' is the very real possibility of leaving the cat process
	running if the program terminates on it's own (that is, not due
	to an end of file from the termination of cat).  This can result
	in strange occurrences where some of your input is taken by the
	cat process and shipped to nowhere while the rest is taken by the
	shell.

Not so.  When the program terminates the 'cat' gets a SIGPIPE
signal which kills it off.

-- 
spoken:	mark weiser
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!mark
CSNet:	mark@umcp-cs
ARPA:	mark.umcp-cs@UDel-Relay