Redirection, Xterms, and Flushing STDIN

James Cameron jc at raven.bu.edu
Tue Mar 5 20:37:52 AEST 1991


First of all, thanks to all you responded to my xterm question regarding
redirection.  The solution is:

$ xterm -e sh -c 'A SHELL COMMAND'

ie, the solution for me was:

$ xterm -title DEMO -name DEMO -e sh -c 'demo1 input/sentences_1 < input/numbers_1'

(Sorry for the length of that...I too hate seeing long lines in
 articles)


Ok, I have come across another problem now.  It seems something funny
is happening with my C program concerning the redirection.  What I
want to happen is that after my output finishes, I want it to ask
the user to hit enter to continue.  The reason for this is that I am
executing it in an xterm and if I don't have some kind of wait command
the xterm will finish upon completetion of said program.  

For some reason, fflush(stdin) doesn't clear it for me when I 
use this redirection.  

The ugly solution is to add a shell prompting script to the end of
that xterm execution string such as

'demo1 input/sentences_1 < input/numbers_1;demowait'

but that seems to be an unnecessary workaround.

The code in the C program to wait is simply this:

  printf("\n\nHit <enter> to close window: ");
  fflush(stdin);
  fflush(fp);
  ch = getchar();

If anyone has any ideas, I would greatly appreciate it.

JC

--
James Cameron  -  jc at raven.bu.edu

Signal Processing and Interpretation Lab, ECS Engineering Dept.
	Boston University, Boston MA
	Work: 617 353-2879
Information Technology
	Boston University, Boston MA
	work: 617 353-2780 ext. 338

		"But to risk we must, because the greatest hazard in life
	is to risk nothing.  For the man or woman who risks nothing, has
	nothing, does nothing, is nothing."

	(A quote from the eulogy for the late Christa McAuliffe.)



More information about the Comp.unix.questions mailing list