[comp.windows.x] XTERM and redirection.

jc@raven.bu.edu (James Cameron) (03/04/91)

I am trying to do some fairly simple demos in C.  Now, to add a little
"excitement" to them, I want a script to open up an xterm and have the 
standard output go to the xterm.  However, I need to do some redirection:
ie I WANT to call it like this:

$ xterm -name DEMO -title DEMO -e 'demo2 input/sentences_1 < input/numbers_1'

but what I get from the xterm is:

	xterm: Can't execvp a.out input/sentences_1 < input/numbers_1

Apparently the C code in the xterm can't handle the redirection.

I have tried it without the quotes, but then it sits on STDIN wanting
the numbers that it was suppose to get from the file.  

Now, I have gotten other demos going using xterm when redirection wasn't
necessary...Any pointers would be greatly appreciated.

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.)

swick@athena.mit.EDU (Ralph Swick) (03/05/91)

    I need to do some redirection:
    ie I WANT to call it like this:

    $ xterm -name DEMO -title DEMO -e 'demo2 input/sentences_1 < input/numbers_1'

    but what I get from the xterm is:

	xterm: Can't execvp a.out input/sentences_1 < input/numbers_1

    Apparently the C code in the xterm can't handle the redirection.

The 'execvp' in the error message should perhaps have given a clue.
The C code in xterm doesn't do anything special at all; to get
shell command interpretations, try

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

Note especially                 ^^^^^

Alternatively, you could re-write the demo2 script to parse its
arguments looking for the token "<" and use

xterm -name DEMO -title DEMO -e demo2 input/sentences_1 '<' input/numbers_1

Ugly.

The trick is to keep straight by whom and when the arguments are parsed.

cjmchale@cs.tcd.ie (Ciaran McHale) (03/05/91)

In <JC.91Mar4102239@raven.bu.edu> jc@raven.bu.edu (James Cameron) writes:

>[...] I need to do some redirection: ie I WANT to call it like this:
>
>xterm -name DEMO -title DEMO -e 'demo2 input/sentences_1 < input/numbers_1'
>
>but what I get from the xterm is: [errors]

One way is to create a file, say, foo which contains the following:

----cut here; start of foo----
#!/bin/sh
demo2 input/sentences_1 < input/numbers_1
----cut here; end of foo----

Then make sure that the execute bit on foo is set so
that foo is a proper executable shell script. Then do:

xterm -name DEMO -title DEMO -e foo


By the way, 14 lines is a bit long for a .signature; please
trim it.


Regards,
Ciaran.
-- 
Ciaran McHale		"Verbosity says it all"			      ____
Department of Computer Science, Trinity College, Dublin 2, Ireland.   \  /
Telephone: +353-1-772941 ext 1538	FAX: +353-1-772204	       \/
Telex: 93782 TCD EI			email: cjmchale@cs.tcd.ie