jc@raven.bu.edu (James Cameron) (03/05/91)
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@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.)
jik@athena.mit.edu (Jonathan I. Kamens) (03/07/91)
In article <JC.91Mar5053752@raven.bu.edu>, jc@raven.bu.edu (James Cameron) writes: |> printf("\n\nHit <enter> to close window: "); |> fflush(stdin); |> fflush(fp); |> ch = getchar(); From the man page fflush(3): Fflush causes any buffered data for the named output stream to be written to that file. The stream remains open. ... These routines return EOF if stream is not associated with an output file, or if buffered data cannot be transferred to that file. Stdin is not an output file. Why are you trying to flush stdin? Perhaps you meant to be flushing stdout? -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710