'xterm -e...' can't handle shell metacharacters

'xterm -e...' can't handle shell metacharacters

Post by Rei » Thu, 17 Oct 1996 04:00:00



When I start an xterm window, and specify a command to run with the
-e switch, such as:

xterm -e 'cmd > cmd.log'

xterm complains that it "Can't execvp cmd > cmd.log".  Is there a way
to accomplish this even when the target of the -e is somewhat complex?
For example, I have cases where I want two different commands to run
within the same xterm window, and I want to redirect the output from
each command to a logfile using 'tee'. The only way I have found to
do this is to first write the target commandlines into a shell script
such as:

cat >tmpscript
#!/bin/sh

cmd1 | tee cmd1.log
cmd2 | tee cmd2.log
^D

Then, start xterm with:

xterm -e tmpscript

Is there a better way?

Thanks very much,
Bruce Reid

 
 
 

'xterm -e...' can't handle shell metacharacters

Post by Thomas Porn » Fri, 18 Oct 1996 04:00:00




Quote:>When I start an xterm window, and specify a command to run with the
>-e switch, such as:

>xterm -e 'cmd > cmd.log'

[...]

Why not using something like : xterm -e /bin/sh -c 'cmd > cmd.log'

You need a shell to handle the metacharacters ...

        --Thomas

PS : disclaimer : I just woke up and this post could be perfect nonsense.

 
 
 

'xterm -e...' can't handle shell metacharacters

Post by Ken Pizzi » Sun, 20 Oct 1996 04:00:00






>>When I start an xterm window, and specify a command to run with the
>>-e switch, such as:

>>xterm -e 'cmd > cmd.log'
>[...]

>Why not using something like : xterm -e /bin/sh -c 'cmd > cmd.log'

>You need a shell to handle the metacharacters ...

>    --Thomas

>PS : disclaimer : I just woke up and this post could be perfect nonsense.

Nope, perfect sense.  I just wanted to suggest a minor optimization:
    xterm -e /bin/sh -c 'exec cmd > cmd.log'

This follows the principle of: why leave the shell* around
using up VM when it isn't necessary?  Of course, it isn't really
all that much VM, and VM is typically vast and cheap these days,
so your preferences may vary.

                --Ken Pizzini

 
 
 

1. in 'getopt()', how to handle multiple options in the 'optarg' string?

Hi All,

Pardon the possible idiocy of this question:

I'm trying to use the 'getopt' routine for handling command-line flags and
while most of it works like a charm, I need to have 1 flag that has 2
arguments:

progname -g 10 filename  yadda yadda yadda

optarg is declared as an 'extern char *', as per the man page for this,
and after the call to getopt, is supposed to point to the beginning of the
variable string.  I read this to mean that after the call, optarg should
point to the string "10 filename".

However, using an intermediate pointer 'tempstr' (because I can't examine
'optarg' directly for some reason (Is that a clue?)), I see with my
debugger that after:
   .
   .
while ((c = getopt(argc, argv, "Lsvqhf:n:o:m:M:b:e:R:g:l:t:T:C:F:w:")) != EOF)
   .
   .
tempstr = optarg;

<now look at tempstr in memory, from the above example>

1 0 \0 f i l e n a m e \0

it looks like it's there but as 2 null-terminated strings instead of one,
so I can't read it in with a 'sscanf()' or suchlike.

Two questions:
1) Is this the correct action of getopt? (almost certainly 'yes' - I'm a
novice at this)

2) What is the usual way of extracting multiple options per flag using getopt?

Thanks in advance for any enlightenment.
Cheers
harry
--
Harry J Mangalam, MolBio+Biochem / Dev+Cell Bio, Rm 4201, BioSciII  UC
Irvine, Irvine, CA, 92717, (714) 824-4824, fax (714) 824 8598
--
Harry J Mangalam, MolBio+Biochem / Dev+Cell Bio, Rm 4201, BioSciII  UC Irvine, Irvine, CA, 92717, (714) 824-4824, fax (714) 824 8598

2. crc error

3. 'less','more' turn xterm inverse video

4. Newbie: mfsroot fouls on install

5. BRU for unix backups?

6. 'more' and 'less' cause inverse video in xterms

7. LILO and Large IDE's

8. Q : Digital Unix 4.0 login problem : 'No directory!' & 'No shell!'

9. Handling of '&' by shell

10. shell 'rc' and 'sudo'

11. Convert 'a' to 'A' in a Shell-Script

12. De-escaping the ';' in an 'rc' shell command ??