Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > system command question

Reply
Thread Tools

system command question

 
 
Himal
Guest
Posts: n/a
 
      09-10-2003
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"
 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      09-10-2003
Himal wrote:
> 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.

 
Reply With Quote
 
 
 
 
Chris Mattern
Guest
Posts: n/a
 
      09-12-2003
Himal wrote:
> 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

 
Reply With Quote
 
Andreas Kahari
Guest
Posts: n/a
 
      09-12-2003
In article <(E-Mail Removed)>, Chris Mattern wrote:
> Himal wrote:
>> 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"


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.

--
Andreas Kähäri
 
Reply With Quote
 
Chris Mattern
Guest
Posts: n/a
 
      09-12-2003
Andreas Kahari wrote:
> In article <(E-Mail Removed)>, Chris Mattern wrote:
>
>>Himal wrote:
>>
>>>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"

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

 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      09-15-2003
Chris Mattern <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> Andreas Kahari wrote:
> > In article <(E-Mail Removed)>, Chris Mattern wrote:
> >
> >>Himal wrote:
> >>
> >>>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"


[...]

> 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
 
Reply With Quote
 
none
Guest
Posts: n/a
 
      10-26-2003
In article <bk4l5q$1uv$(E-Mail Removed)-Berlin.DE>,
Anno Siegel <(E-Mail Removed)-berlin.de> wrote:
>> 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.


It's zsh syntax.

Ben
--
And if you wanna make sense / Whatcha looking at me for? (Fiona Apple)
* http://www.velocityreviews.com/forums/(E-Mail Removed) *
 
Reply With Quote
 
Roderick Allen
Guest
Posts: n/a
 
      10-27-2003
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


none wrote:

>In article <bk4l5q$1uv$(E-Mail Removed)-Berlin.DE>,
>Anno Siegel <(E-Mail Removed)-berlin.de> wrote:
>
>
>>>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.
>>
>>

>
>It's zsh syntax.
>
>Ben
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
suppress opening command window after using os.system command boriq Python 4 06-12-2008 10:42 AM
System.Security.SecurityException: Error de solicitud de permiso de tipo System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. Luis Esteban Valencia ASP .Net 0 07-14-2005 01:43 PM
RUN/execute a Command-Line command from an ASP page. Lucas Cowald ASP .Net 4 10-23-2003 11:09 AM
os.system('cd dir1 ... and executing next os.system command in that directory (dir1) Irmen de Jong Python 2 08-12-2003 12:43 PM
copying value of DDL in a Datagrid "pre-edit command" to value in "post edit command" San Diego Guy ASP .Net 0 08-07-2003 08:59 PM



Advertisments