system command question

H

Himal

I there a reason why a command will not work if i do system "$cmd &>
xyz.log" even though it works if I do system "$cmd"
 
J

J. Gleixner

Himal said:
I there a reason why a command will not work if i do system "$cmd &>
xyz.log" even though it works if I do system "$cmd"

This is an OS/Shell issue.

From your command line try:

whateverCommandYouAreTryingToRun & > xyz.log

and you should see the error.
 
C

Chris Mattern

Himal said:
I there a reason why a command will not work if i do system "$cmd &>
xyz.log" even though it works if I do system "$cmd"

Most likely, the shell perl is using to parse your command is
not csh. Exactly why this is so would depend on your configuration.
Try this, which will work for sh/ksh/bash: system "$cmd >xyz.log 2>&1"

Chris Mattern
 
A

Andreas Kahari

Most likely, the shell perl is using to parse your command is
not csh. Exactly why this is so would depend on your configuration.
Try this, which will work for sh/ksh/bash: system "$cmd >xyz.log 2>&1"

There is no reason for it to be csh. The manual for the system
command says:

If there is only one scalar argument, the argument is
checked for shell metacharacters, and if there are any, the
entire argument is passed to the system's command shell for
parsing (this is "/bin/sh -c" on Unix platforms, but varies
on other platforms). If there are no shell metacharacters
in the argument, it is split into words and passed directly
to "execvp", which is more efficient.

So it's either /bin/sh (on Unix systems) or no shell at all.,
if you haven't done some pretty freakish changes in the default
configuration.
 
C

Chris Mattern

Andreas said:
There is no reason for it to be csh. The manual for the system
command says:

If there is only one scalar argument, the argument is
checked for shell metacharacters, and if there are any, the
entire argument is passed to the system's command shell for
parsing (this is "/bin/sh -c" on Unix platforms, but varies
on other platforms). If there are no shell metacharacters
in the argument, it is split into words and passed directly
to "execvp", which is more efficient.

So it's either /bin/sh (on Unix systems) or no shell at all.,
if you haven't done some pretty freakish changes in the default
configuration.

Ah, OK, I thought it used the user's shell. OK, then,
system "$cmd >xyz.log 2>&1" should be the answer, assuming
the OP is on a Unix system (which seems logical, since he's
trying to use csh syntax).

Chris Mattern
 
A

Anno Siegel

Chris Mattern said:
[...]

Ah, OK, I thought it used the user's shell. OK, then,
system "$cmd >xyz.log 2>&1" should be the answer, assuming
the OP is on a Unix system (which seems logical, since he's
trying to use csh syntax).

Except that he isn't. "$cmd >& xyz.log" would be csh syntax.
"$cmd &> xyz.log" is neither here nor there.

Anno
 
R

Roderick Allen

Can you not precede the entire command with /usr/bin/csh if you want to
execute it under the csh? For example, system("csh $cmd >& xyz.log");

Rod

Except that he isn't. "$cmd >& xyz.log" would be csh syntax.
"$cmd &> xyz.log" is neither here nor there.

It's zsh syntax.

Ben
[/QUOTE]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top